Jump to content
  • 0

Помогите новичку


tolyan
 Share

Question

Дело такое, начал потихоньку осваивать блочную верстку, освоил и сверстал странички с помощью float, решил начать осваивать верстку с помощью не только float, но и с помощью позиционирования, решил для начала сделать один вертикальный блок, один горизонтальный и один тоже вертикальный но немножко находящий на первый, вроде всё довольно быстро получилось, но как быть если мои блоки не заходят в контейнер, точнее они себя ведут как в контейнере, но при этом контейнер как будто выше них, в этом я убедился, придав контейнеру рамку... в случае, где я располагал блоки с помощью float это лечилось тем, что я после всех блоков производил отчистку "clear:boch", а здесь это не помогает...

Как быть в этом случае если я, например, хочу всей страничке придать рамку....

Вот код, если я что-то непонятно переспросите, пожалуйста…

*css*

_________

* {

margin: 0;

border:0;

padding:0;

}

#container {

margin: auto;

width:700px;

position:relative;

border:3px solid #FF0000 ;

}

#header {

width: 100%;

height: 120px;

position:absolute;

background:#000;

}

#vertical {

width:100px;

height: 300px;

background: #990000;

position:relative;

left: 100px;

top:120px;

float:left;}

#dop {

width:300px;

height:50px;

position:absolute;

top:100px;

left:50%;

background-color: #999933;

}

.clear{

clear:both;

}

*html*

___________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

<title>position</title>

<link href="style.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div id="container">

<div id="header"></div>

<div id="vertical"></div>

<div id="dop"></div>

</div>

</body>

</html>

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0
Как быть в этом случае если я, например, хочу всей страничке придать рамку....

Вот код, если я что-то непонятно переспросите, пожалуйста…

Не раз подымалась тема на форуме. Читать про overflow:hidden;

Link to comment
Share on other sites

  • 0

Проблемка остается:

Когда вертикальный блок больше контента, то все отлично, а когда вертикальный блок меньше контента, то все ужасно, "лишний" просто текст откусывается, и всё ^_^ ... подскажите, наверно надо еще что-то доработать...

Заранее извиняюсь, но надеюсь на помощь...

*Css*

_________

* {

margin: 0;

border:0;

padding:0;

}

#container {

margin: auto;

width:700px;

position:relative;

border:3px solid #FF0000 ;

overflow:hidden;

}

#header {

width: 100%;

height: 120px;

position:absolute;

background:#000;

}

#vertical {

width:100px;

height: 400px;

background: #990000;

position:relative;

top:120px;

float:left;

}

#dop {

width:300px;

height:50px;

position:absolute;

top:100px;

left:50%;

background-color: #999933;

}

#text {

width:600px;

position:relative;

top:150px;

float:right;

}

.clear {

clear:both;

}

*html*

_____________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

<title>position</title>

<link href="style.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div id="container">

<div id="header"></div>

<div id="vertical"></div>

<div id="text">

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div id="dop"></div>

<div class="clear"></div>

</div>

</body>

</html>

Проблемка остается:

Когда вертикальный блок больше контента, то все отлично, а когда вертикальный блок меньше контента, то все ужасно, "лишний" просто текст откусывается, и всё :P ... подскажите, наверно надо еще что-то доработать...

Заранее извиняюсь, но надеюсь на помощь...

*Css*

_________

* {

margin: 0;

border:0;

padding:0;

}

#container {

margin: auto;

width:700px;

position:relative;

border:3px solid #FF0000 ;

overflow:hidden;

}

#header {

width: 100%;

height: 120px;

position:absolute;

background:#000;

}

#vertical {

width:100px;

height: 400px;

background: #990000;

position:relative;

top:120px;

float:left;

}

#dop {

width:300px;

height:50px;

position:absolute;

top:100px;

left:50%;

background-color: #999933;

}

#text {

width:600px;

position:relative;

top:150px;

float:right;

}

.clear {

clear:both;

}

*html*

_____________________

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />

<title>position</title>

<link href="style.css" rel="stylesheet" type="text/css" />

</head>

<body>

<div id="container">

<div id="header"></div>

<div id="vertical"></div>

<div id="text">

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

<div id="dop"></div>

<div class="clear"></div>

</div>

</body>

</html>

Edited by tolyan
Link to comment
Share on other sites

  • 0

Решил попробовать верстку блоками, вначале с float, там всё получилось, потом решил попробовать еще и с позиционированием, решил для начала сделать простой наглядный макетик, все довольно быстро получилось, но получается вот такое что блоки ведут себя как в контейнере, но фактически не в нем, в этом я убедился, поставив бордер, там где я делал с float, это исправлялось clear:both; , но здесь это не работает….

180983.gif

Чтобы все блоки загнать в контейнер, у которого рамка, мне посоветовали поставить overflow:hidden;, с ним всё получается, если вертикальный блок больше блока с текстом, но в моем случае он меньше и получается абра-кодабра - “лишний” текст просто обрезается.

280984.gif

*CSS*

* {
margin: 0;
border:0;
padding:0;
}
#container {
margin: auto;
width:700px;
position:relative;
border:5px solid #FF0000 ;
/*отсюда убрал пока - overflow: hidden;*/
}
#header {
width: 100%;
height: 120px;
position:absolute;
background:#000;
}
#vertical {
width:100px;
height: 400px;
background: #990000;
position:relative;
top:120px;
float:left;
}
#dop {
width:300px;
height:50px;
position:absolute;
top:100px;
left:50%;
background-color: #999933;
}
#text {
width:585px;
position:relative;
top:150px;
padding: 5px;
float:right;

}
.clear {
clear:both;
}

*html*

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>position</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<div id="header"></div>
<div id="vertical"></div>
<div id="text">
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
<div id="dop"></div>
</div>
</body>
</html>

Link to comment
Share on other sites

  • 0

Вот Вам почва для размышлений:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<style type="text/css">

/*
###########################################################################
#########################
[1. Page configuration]
###########################################################################
#########################

—————————————————————————————————-
[1.1 Defaults Tags options]
—————————————————————————————————-
*/
* html { font-size:100%; } /* for IE */
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 0.625em; /* default page font size is 10px (1em) */
min-width: 100.8em; /* Default scroll width is 16px, so 1024-16 is 1008px */
position:relative;
border:1px solid #f0f;
}

* { margin: 0; padding: 0; outline: none; }

ul { list-style-type: none;}
img { border: none; }
table { border-collapse: collapse; }


/* HEADER */
div.hdr { background-color:#333; height:10.0em; }
div.hdr p { text-align:center; font-size:1.6em; color:#fff; }

/* Extended */
div.ext {
position:absolute;
left:50%; top:25%;
width:24.0em;
height:6.0em;
background-color:#9C6;
}

/* Content container */
div.data { overflow:hidden; _zoom: 1; }

/* side bar */
div.sb { float:left; width: 25.0em; background-color:#3ff; _margin-right:-25.0em; }

/* content */
div.content { margin-left:25.0em; background-color:#fcfcfc; }

</style>

</head>

<body>

<!-- header -->
<div class="hdr">
<p>Header</p>
</div>

<!-- extended -->
<div class="ext"></div>

<!-- data container -->
<div class="data">

<!-- side bar -->
<div class="sb">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.</p>
</div>

<!-- content -->
<div class="content">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br />
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br /></p>
</div>

</div>

</body>
</html>

Link to comment
Share on other sites

  • 0

А нельзя на моем примере еще рассмотреть, я знаю что вполне можно и с Float это сделать, но хотелосьбы для начала на таком не сложном примере разобрать именно с позиционированием, ведь более сложные элементы именно на позиционирование делаются....

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy