how to make a two layout columns with same height with right column offset to header
I want to create a blogger design with 2 column layout, the right column positioned top as same as header but also I want its height to be approaching on the footer regardless of the the content of left column.
Here's the layout I want to be:
CSS Code:
#center {
float: left;
overflow: hidden;
background: #f0f0f0;
}
#center div 开发者_Python百科{
float: left;
margin-bottom: -2000px;
padding-bottom: 2000px;
}
#center .col1 {
width:700px;
margin-right: 5px;
}
#center .col2 {
margin-right: 0;
width:200px;
background:#000000;
overflow:hidden;
}
.clear {
clear:both;
display:block;
overflow:hidden;
visibility:hidden;
width:0;
height:0
}
.content {
padding:10px;
}
.footer {
background:#99FF99;
}
.sidebar {
margin-left: 5px;
margin-right: 5px;
color:#FFFFFF;
}
#Image1 {
position:absolute;
top:10px;
}
HTML Code:
<div class="container">
<div class="header-wrapper">
<div class="header">
<h1>Blog Title</h1>
Integer nec neque. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent dictum venenatis velit. Morbi interdum eleifend sapien. Morbi a mauris</div>
</div>
</div>
<div class="clear"></div>
<div class="container">
<div id="center" class="grid">
<div class="col1">
<div class="content">
<p>Left Content</p>
</div>
</div>
<div class="col2">
<div class="content sidebar">
<div id="Image1" class="widget Image">
<div class="widget-content"> <img width="180" height="201" src="Image SRc" id="Image1_img" alt=""> <br>
</div>
</div>
<p>righ text</p>
</div>
</div>
</div>
</div>
<div class="clear"></div>
<div class="container">
<div class="footer">Footer</div>
</div>
If you just want the answer without taking the journey, here:
CSS:
<style media="screen" type="text/css">
#container2 {
clear:left;
float:left;
width:100%;
overflow:hidden;
background:#ffa7a7; /* column 2 background colour */
}
#container1 {
float:left;
width:100%;
position:relative;
right:50%;
background:#fff689; /* column 1 background colour */
}
#col1 {
float:left;
width:46%;
position:relative;
left:52%;
overflow:hidden;
}
#col2 {
float:left;
width:46%;
position:relative;
left:56%;
overflow:hidden;
}
#footer {
clear:both;
float:left;
width:100%;
}
</style>
HTML
<div id="header">
</div>
<div id="container2">
<div id="container1">
<div id="col1">
</div>
<div id="col2">
</div>
</div>
</div>
<div id="footer">
</div>
DEMO
精彩评论