I saw two column layout made as following way, but I didn't understand why it works.
So what actually does the .col-sub
do? If I remove margin-left:-100%
in .col-sub
, the Sub Content will fall down. If I remove float: left
in it, the Sub Content can't show. What does margin-left and float do here?
Demo can also be found here: http://jsfiddle.net/yougen/ATNh9/
HTML:
<div class="wrapper">
<div class="col-main">Main Content</div>
<div class="col-sub">Sub Content</div>
</div>
CSS:
* {
padding:0;
margin: 0;
}
.wrapper {
margin: 0px auto;
width: 960px;
text-align: center;
line-height: 580px;
}
.col-main {
width:100%;
height:580px;
float: left;
background-color: #f16529;
border: solid 1px #000;
}
.col-sub {
float: left;
margin-left: -100%;/** -960px **/
width: 350px;
height: 580px;
background-color: #f0dddd;
}