hi guys i've managed to create my css layout but whenever i try to set body_second and body_third to 100% it causes the screen to overflow. i don't want to invoke the scrollbar in any case.
i would like the css layout to resize to the window size without any need for overflow as seen on http://biblia.com/ * try to resize the window when on the website in different browsers, i'm trying to achieve the same thing!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>100% Height CSS Layout</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
* {
pad开发者_Go百科ding: 0;
margin: 0;
}
html, body {
height: 100%;
width: 100%;
background-image:url(main_bg.png);
}
body {
font-family: "lucida sans", verdana, arial, helvetica, sans-serif;
font-size: 75%;
}
h1 {
font-size: 1.4em;
padding: 10px 10px 0;
}
p {
padding: 0 10px 1em;
}
#container {
min-height: 100%;
border-left: 0px solid #666;
border-right: 0px solid #666;
padding: 0px 40px 0px 40px;
margin: 0 auto;
}
* html #container {
height: 100%;
}
#header {
height: 40px;
width: 100%;
}
.header_column {
position: absolute;
padding-top: 10px;
}
#header_second {
margin-left: 50%;
color:#FFF;
}
#header_third {
margin-left: 80%;
color:#FFF;
}
#body {
height: 100%;
width: 100%;
margin-top: -2px;
}
.body_column {
position: absolute;
background-color:#FFF;
height: 100%;
overflow: auto;
}
#body_first {
width: 22%;
background-color: #EAEAEA;
min-height: 60%;
}
#body_second {
margin-left: 22%;
width: 36%;
background-color:#FFF;
min-height: 85%;
max-height: 90%;
}
#body_third {
margin-left: 58%;
width: 36%;
border: 1px;
background-color: #919191;
min-height: 85%;
}
#footer {
margin-top: 70%;
position: absolute;
}
</style>
</head>
<body>
<div id="container">
<div id="header">
<div id="header_first" class="header_column"><img src="header_logo.png" width="35" height="16" border="0"></div>
<div id="header_second" class="header_column">asdas</div>
<div id="header_third" class="header_column">asdas</div>
</div>
<div id="body">
<div id="body_first" class="header_column">asdas</div>
<div id="body_second" class="header_column">asdas</div>
<div id="body_third" class="header_column">asdas</div>
</div>
<div id="footer">asdas</div>
</div>
</body>
</html>
It's your margins! If you set set #body_second's width to 100% of it's parent's width then add margin-left: 22% (essentially offsetting it 22% away from its parent's left side).. together.. it's going to overflow because that adds up to > 100%.
精彩评论