我想调整我的菜单的浮动部分左边,其他部分右边。但是,我无法让它工作。浮动div左边,其他div右边
我一直在尝试使用float
来完成它,但我无法完成它的工作。
我该如何以正确的方式做到这一点?
HTML
<div class="topbar">
<div class="title">Title</div>
<div class="topbar-boxes">
<div class="topbar-boxes-left">
<div class="topbar-box">Box1</div>
<div class="topbar-box">Box2</div>
<div class="topbar-box">Box3</div>
</div>
<div class="topbar-boxes-right">
<div class="topbar-box">Box1</div>
<div class="topbar-box">Box2</div>
<div class="topbar-box">Box3</div>
</div>
</div>
<div style="clear:both"></div>
</div>
CSS
.topbar {
width: 100%;
padding: 14px;
font-size: 18pt;
color: white;
background-color: rgba(42, 42, 42, 0.95);
}
.title {
float: left;
padding-right: 50px;
}
.topbar-boxes {
float: left;
margin: -14px;
}
.topbar-boxes-left {
float: left;
}
.topbar-boxes-right {
float: right;
}
.topbar-box {
float: left;
padding: 20px;
border-left: 1px solid black;
}
了解[如何](http://stackoverflow.com/a/16568504/1542290)了解浮动工作原理。 –
尝试将float用于您的某个类,而不是将它用于所有类 –