body box being generate only for half of the page
In the html page here: http://pastehtml.com/view/axfov9710.html box for body
tag is being generated only till the pink boxes in the middl开发者_运维问答e and the float
boxes in the bottom are being left out. This I checked using Firebug and Chrome web inspector. This is creating problem when I am trying to extract the geometry of page elements programatically. How can I enforce box corresponding to body tag to the whole page.
HTML markup:
<html>
<head>
<title>Page</title>
<style type="text/css">
body {
width: 1000px;
margin-left: auto;
margin-right: auto;
}
#header {
height: 200px;
margin: 2px;
margin-bottom: 10px;
font-family: Arial,Helvetica,sans-serif;
font-size: XX-large;
}
#first_half {
margin-bottom: 20px;
overflow: hidden;
}
#first_half div.summaries_box {
float: left;
margin-right: 10px;
width: 550px;
}
#para_right {
float: right;
width: 440px;
background-color: gray;
}
#second_half {
clear: both;
}
#second_half div.summaries_box {
float: left;
margin-left: auto;
margin-right: auto;
margin-top: 20px;
clear: both;
}
div.summary {
width: 260px;
margin: 5px;
float: left;
background: lightblue;
}
h3.summary_header {
font-weight: bold;
font-variant: small-caps;
}
#snippets_horizontal {
width: 90%;
margin-left: auto;
margin-right: auto;
overflow: hidden;
}
#snippets_horizontal .snippet {
float: left;
width: 45%;
margin-right: 5%;
font-size: small;
background-color: lightpink;
}
</style>
</head>
<body>
<div id="header">
<p>Lorem ipsum dolor sit amet</p>
</div>
<div id="first_half">
<div class="summaries_box">
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
</div>
<div id="para_right" class="para">
<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.
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>
<div id="second_half">
<div id="snippets_horizontal">
<div class ="snippet">
<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</p>
</div>
<div class ="snippet">
<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</p>
</div>
</div>
<div class="summaries_box">
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
<div class="summary">
<h3 class="summary_header">Lorem ipsum dolor sit amet</h3>
<ul class="summary_list">
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
<li class="summary_title_snip"><p>Lorem ipsum dolor sit amet</p></li>
</ul>
</div>
</div>
</div>
</body>
#second_half need clearfix.
#second_half {
clear: both;
overflow: hidden;
_zoom: 1; /* for ie6 */
}
I would put another "container" tag just under your body tag and ending just before the body finishes then apply the width to that and not the body.
<body>
<div id"container">
...
</div>
</body>
The answer is combination of what is provided by clyfish and Magnum. Applying a <div>
to the float with overflow: hidden;
style property.
精彩评论