Добро пожаловать! Это — архивная версия форумов на «Хакер.Ru». Она работает в режиме read-only.
 

Нужна помощь с расстановкой div'ов

Пользователи, просматривающие топик: none

Зашли как: Guest
Все форумы >> [Web-дизайн] >> Нужна помощь с расстановкой div'ов
Имя
Сообщение << Старые топики   Новые топики >>
Нужна помощь с расстановкой div'ов - 2008-10-13 22:00:33.020000   
Mamka

Сообщений: 560
Оценки: 0
Присоединился: 2007-11-26 22:20:09.313333
Создаю страницу в дриме по макету страницу.
&lt;div id="container"&gt; &lt;div id="header"&gt; &lt;!-- end #header --&gt;&lt;/div&gt; &lt;div id="sidebar1"&gt; &lt;!-- end #sidebar1 --&gt;&lt;/div&gt; &lt;div id="mainContent"&gt; &lt;!-- end #mainContent --&gt;&lt;/div&gt; &lt;br class="clearfloat" /&gt; &lt;div id="footer"&gt; &lt;!-- end #footer --&gt;&lt;/div&gt; &lt;!-- end #container --&gt;&lt;/div&gt; Нужно сделать рамку(не бордерами, а текстуру пустить) по бокам sidebar1'a и maincontent'a.
Где нужно вставить дивы и какими св-ми они должны обладать?
Пробывал открыть и сразу закрыть див перед sidebar1, поставил backround-image и backround-repeat y и float-left. В таком случае он делал рамку слева, но размер приходилось устанавливать в ручную, а мне нужно, что бы он был равен высоте sidebar1'a и maincontent'a.
Прошу порщение за ламерство, но я только начал разбираться с этим.
Post #: 1
RE: Нужна помощь с расстановкой div'ов - 2008-10-13 22:50:38.243333   
zhuk

Сообщений: 2962
Оценки: 10
Присоединился: 2007-02-20 21:00:01.303333
Выкладывай CSS

PS: есть вообще опыт верстки, или это первая проба? Все-таки дивы - вещь сложная. Если в первый раз, попробуй сначала таблицы.
Post #: 2
RE: Нужна помощь с расстановкой div'ов - 2008-10-13 23:50:55.486666   
Mamka

Сообщений: 560
Оценки: 0
Присоединился: 2007-11-26 22:20:09.313333

Сам код+стили(выложил весь файл по дефолту). zhuk, если сам вставишь эти дивы-буду крайне признателен.

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Untitled Document&lt;/title&gt; &lt;style type="text/css"&gt; &lt;!-- body { font: 100% Verdana, Arial, Helvetica, sans-serif; background: #666666; margin: 0; /* it's good practice to zero the margin and padding of the body element to account for differing browser defaults */ padding: 0; text-align: center; /* this centers the container in IE 5* browsers. The text is then set to the left aligned default in the #container selector */ color: #000000; } .twoColHybLtHdr #container { width: 80%; /* this will create a container 80% of the browser width */ background: #FFFFFF; margin: 0 auto; /* the auto margins (in conjunction with a width) center the page */ border: 1px solid #000000; text-align: left; /* this overrides the text-align: center on the body element. */ } .twoColHybLtHdr #header { background: #DDDDDD; padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear beneath it. If an image is used in the #header instead of text, you may want to remove the padding. */ } .twoColHybLtHdr #header h1 { margin: 0; /* zeroing the margin of the last element in the #header div will avoid margin collapse - an unexplainable space between divs. If the div has a border around it, this is not necessary as that also avoids the margin collapse */ padding: 10px 0; /* using padding instead of margin will allow you to keep the element away from the edges of the div */ } /* Tips for sidebar1: 1. Since we are working in relative units, it's best not to use padding on the sidebar. It will be added to the overall width for standards compliant browsers creating an unknown actual width. 2. Since em units are used for the sidebar value, be aware that its width will vary with different default text sizes. 3. Space between the side of the div and the elements within it can be created by placing a left and right margin on those elements as seen in the ".twoColHybLtHdr #sidebar1 p" rule. */ .twoColHybLtHdr #sidebar1 { float: left; width: 12em; /* since this element is floated, a width must be given */ background: #EBEBEB; /* the background color will be displayed for the length of the content in the column, but no further */ padding: 15px 0; /* top and bottom padding create visual space within this div */ } .twoColHybLtHdr #sidebar1 h3, .twoColHybLtHdr #sidebar1 p { margin-left: 10px; /* the left and right margin should be given to every element that will be placed in the side columns */ margin-right: 10px; } /* Tips for mainContent: 1. The space between the mainContent and sidebar1 is created with the left margin on the mainContent div. No matter how much content the sidebar1 div contains, the column space will remain. You can remove this left margin if you want the #mainContent div's text to fill the #sidebar1 space when the content in #sidebar1 ends. 2. Be aware it is possible to cause float drop (the dropping of the non-floated mainContent area below the sidebar) if an element wider than it can contain is placed within the mainContent div. WIth a hybrid layout (percentage-based overall width with em-based sidebar), it may not be possible to calculate the exact width available. If the user's text size is larger than average, you will have a wider sidebar div and thus, less room in the mainContent div. You should be aware of this limitation - especially if the client is adding content with Contribute. 3. In the Internet Explorer Conditional Comment below, the zoom property is used to give the mainContent "hasLayout." This may help avoid several IE-specific bugs. */ .twoColHybLtHdr #mainContent { margin: 0 20px 0 13em; /* the right margin can be given in percentages or pixels. It creates the space down the right side of the page. */ } .twoColHybLtHdr #footer { padding: 0 10px; /* this padding matches the left alignment of the elements in the divs that appear above it. */ background:#DDDDDD; } .twoColHybLtHdr #footer p { margin: 0; /* zeroing the margins of the first element in the footer will avoid the possibility of margin collapse - a space between divs */ padding: 10px 0; /* padding on this element will create space, just as the the margin would have, without the margin collapse issue */ } /* Miscellaneous classes for reuse */ .fltrt { /* this class can be used to float an element right in your page. The floated element must precede the element it should be next to on the page. */ float: right; margin-left: 8px; } .fltlft { /* this class can be used to float an element left in your page */ float: left; margin-right: 8px; } .clearfloat { /* this class should be placed on a div or break element and should be the final element before the close of a container that should fully contain a float */ clear:both; height:0; font-size: 1px; line-height: 0px; } --&gt; &lt;/style&gt;&lt;!--[if IE]&gt; &lt;style type="text/css"&gt; /* place css fixes for all versions of IE in this conditional comment */ .twoColHybLtHdr #sidebar1 { padding-top: 30px; } .twoColHybLtHdr #mainContent { zoom: 1; padding-top: 15px; } /* the above proprietary zoom property gives IE the hasLayout it may need to avoid several bugs */ &lt;/style&gt; &lt;![endif]--&gt;&lt;/head&gt; &lt;body class="twoColHybLtHdr"&gt; &lt;div id="container"&gt; &lt;div id="header"&gt; &lt;h1&gt;Header&lt;/h1&gt; &lt;!-- end #header --&gt;&lt;/div&gt; &lt;div id="sidebar1"&gt; &lt;h3&gt;sidebar1 Content&lt;/h3&gt; &lt;p&gt;The background color on this div will only show for the length of the content. If you'd like a dividing line instead, place a border on the left side of the #mainContent div if the #mainContent div will always contain more content than the #sidebar1 div. &lt;/p&gt; &lt;p&gt;Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut, sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh. Donec nec libero.&lt;/p&gt; &lt;!-- end #sidebar1 --&gt;&lt;/div&gt; &lt;div id="mainContent"&gt; &lt;h1&gt; Main Content &lt;/h1&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio. Donec et ipsum et sapien vehicula nonummy. Suspendisse potenti. Fusce varius urna id quam. Sed neque mi, varius eget, tincidunt nec, suscipit id, libero. In eget purus. Vestibulum ut nisl. Donec eu mi sed turpis feugiat feugiat. Integer turpis arcu, pellentesque eget, cursus et, fermentum ut, sapien. Fusce metus mi, eleifend sollicitudin, molestie id, varius et, nibh. Donec nec libero.&lt;/p&gt; &lt;h2&gt;H2 level heading &lt;/h2&gt; &lt;p&gt;Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent aliquam, justo convallis luctus rutrum, erat nulla fermentum diam, at nonummy quam ante ac quam. Maecenas urna purus, fermentum id, molestie in, commodo porttitor, felis. Nam blandit quam ut lacus. Quisque ornare risus quis ligula. Phasellus tristique purus a augue condimentum adipiscing. Aenean sagittis. Etiam leo pede, rhoncus venenatis, tristique in, vulputate at, odio.&lt;/p&gt; &lt;!-- end #mainContent --&gt;&lt;/div&gt; &lt;!-- This clearing element should immediately follow the #mainContent div in order to force the #container div to contain all child floats --&gt; &lt;br class="clearfloat" /&gt; &lt;div id="footer"&gt; &lt;p&gt;Footer&lt;/p&gt; &lt;!-- end #footer --&gt;&lt;/div&gt; &lt;!-- end #container --&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt;
Post #: 3
Страниц:  [1]
Все форумы >> [Web-дизайн] >> Нужна помощь с расстановкой div'ов







Связаться:
Вопросы по сайту / xakep@glc.ru

Предупреждение: использование полученных знаний в противозаконных целях преследуется по закону.