CSS: Float.
Mikeybob
Middle o' Farmer Land
Hi everyone,
I'm having some trouble with my page. Basically, it has three main divs. A banner at the top, navigation along the left side and the content to the right of the navigation. The banner is in it's own wrapper (container) div, and so is the navigation and content. There is a main wrapper containing it all.
The problem is that the navigation div is floated left, and the content right. However, the main wrapper height need to change to the height of the navigation or content (whichever is largest) so it contains it all.
I've found out floating divs are placed out of sync with the main flow, so the main wrapper is totally unaffected, and the content wrapper is always 0px high.
This is more or less how it's designed:
This is more or less how it looks:
Any help would be awesome. Thanks .
I'm having some trouble with my page. Basically, it has three main divs. A banner at the top, navigation along the left side and the content to the right of the navigation. The banner is in it's own wrapper (container) div, and so is the navigation and content. There is a main wrapper containing it all.
The problem is that the navigation div is floated left, and the content right. However, the main wrapper height need to change to the height of the navigation or content (whichever is largest) so it contains it all.
I've found out floating divs are placed out of sync with the main flow, so the main wrapper is totally unaffected, and the content wrapper is always 0px high.
This is more or less how it's designed:
This is more or less how it looks:
Any help would be awesome. Thanks .
0
Comments
[HTML] <div id="main_wrapper">
<div id="banner_wrapper">
<img src="images/banner/banner.jpg" alt="">
</div>
<div id="content_wrapper">
<div id="navigation_wrapper">
<div id="navigation_set">
1234
</div>
</div>
<div id="article_wrapper">
<div class="article_set">
1234
</div>
</div>
</div>
</div>[/HTML]
The CSS is:
Thanks again
err wait sorry I just caught the second post, dnno howw I missed it... haha
Thanks for the help anyway .
Second, create a "footer" div (empty if you like) just before the close of the outer wrapper. Set it to "clear:both;". That will cause it to appear BELOW all the floats above, stretching its container down below everything else.
[edit]
This is going to sound like a silly question, but I'm assuming I position whichever div isn't floating using padding.
If you're using relative positioning, then yes, you'd use margin and padding to position/space the elements.
[edit]
I tell a lie. The navigation just sits ontop, as if it's higher on the Z axis.
Also, remove "position: static;" everywhere it appears in your CSS. It's redundant to declare that without reason.
On a similar note; I tried the same technique on another div that's inside the content div. It works in a similar way; four divs: -
Content wrapper: same as before,
Article header (at the top)
Article content (underneath the header and float:left)
Article features (to the right of article content and bumped across by the margin),
Article footer (sits below the content and footer),
Article set (works as a wrapper for the previous four divs).
FF loves it, and it displays fine. IE, on the other hand, sketches out and sticks the features div under the content div (still bumped across by margin).
Mathematically, it should all fit together. I even tried shrinking the content div in case the divs' widths were too wide added together.
Codage:
[HTML]
<body id="page_layout">
<div id="main_wrapper">
<div id="banner_wrapper">
<img src="images/banner/banner.jpg" alt="">
</div>
<div id="content_wrapper">
<div id="navigation_wrapper">
<div id="navigation_heading">
<h1>Projects</h1>
</div>
<div id="navigation_menu">
<ul>
<li><a href="navigation_link">Link</a></li>
</ul>
</div>
</div>
<div id="article_wrapper">
<div class="article_set">
<div class="article_heading">
<h1>Article Title</h1>
<a name="anchor_ID"></a> </div>
<div class="article_content"><a href="image_link"><img src="image_src" alt=""></a>
</div>
<div class="article_features">
<h1>Features:</h1>
<ul>
<li>feature 1</li>
</ul>
</div>
</div>
<div class="article_footer">
<ul>
<li><span class="article_footer_header">Media:</span><span class="article_footer_subtext">123</span></li>
<li><span class="article_footer_header">Date:</span><span class="article_footer_subtext">123</span></li>
</ul>
</div>
</div>
</div>
<div id="footer">
</div>
</div>
</body>
[/HTML]
Thanks again.
P.S. Is span still used?