Clearing block affects wrong floating
I've got two开发者_如何学Python-column layout
<div class="left-pane">
Left pane
</div>
<div class="central-pane">
<div>
<ul class="customers-types-tabs">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
<div>Main content</div>
</div>
and the stylesheet:
.left-pane {
width: 248px;
float: left;
background-color: #f6f6f6;
border: 1px solid #e6e6e6;
padding: 20px 5px;
}
.central-pane {
margin-left: 270px;
}
.customers-types-tabs li {
background-color: #f6f6f6;
border: 1px solid #d5d5d5;
line-height: 38px;
padding: 0 20px;
float: left;
margin-right: 10px;
position: relative;
top: 1px;
}
The problem is that I want "Main content" to appear right below the div with ul inside it (that represents tabs control), but if I set Main content's div's style to clear: both, it appears below the left pane, which is taller than the ul. What should I do to get correct position of main content?
give the central pane also a float: left
and the next element after this construct you give float:none;
and if you want to be shure it works on any browserwindow size put a div around all that with fied width, so that the inner objects fit into it by width. know what i mean?#
<div id="wrapper">
<div class="left-pane">
Left pane
</div>
<div class="central-pane">
<div>
<ul class="customers-types-tabs">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
</div>
<div id="main">Main content</div>
</div>
</div>
<div style="flaot:none;"></div>
and the stylesheet:
#wrapper{
position: relative;
width: 548px;
}
.left-pane {
width: 248px;
float: left;
...
}
.central-pane {
float: left;
width: 200px;
}
#main{
width: 100px;
float: left;
...
}
now they should apear each next to the other
So long I found one solution, but it's not "pretty". Adding
<li style="float: none; visibility: hidden;">stub</li>
as the last item to ul helps solve the problem.
精彩评论