我不知道这是否很难解释,但它就是这样。我的页面上有许多 div,我希望它们以列布局的形式出现。该页面有一个导航栏、一个徽标、一些个人资料数据和另外 3 个 div。这 3 个 div 没有正确对齐。第一个向左浮动,第二个紧随其后,因此也浮动。我希望第三个向右浮动,但与前两个对齐。
看到这个小提琴。
我希望.commitment_box
div 与那些.major_data
.
CSS:
.major_data {
margin: 110px auto;
width: 40%;
}
.major_data .profile_box p:first-child {
border-bottom: 0px;
text-align: center;
font-size: 20px;
margin-top: 0px;
background-color: #eee;
font-weight: bold;
}
.major_data .profile_box p:nth-child(2) {
text-align: justify;
padding-left: 5px;
padding-right: 5px;
margin-top: -20px;
}
.major_data .profile_box p {
border: 1px solid #bbb;
}
.commitment_box { /*the div i want to be floated right in alignment with those about boxes */
margin-top: -58.2%;
text-align: center;
height: 40px;
overflow: hidden;
background-color: lightblue;
color: white;
font-size: 20px;
width: 25%;
margin-right: 2%;
float:left;
}
.commitment_box .commitment p {
display: inline-block;
margin-top: 1.5%;
}
.commitment_box .commitment p:first-child {
font-weight: bold;
margin-right: 20px;
}
HTML:
<div class="commitment_box">
<!--/*the div i want to be floated right in alignment with those about boxes */-->
<div class="commitment">
<p>Alex:</p>
<p>He's works great.aidhoaishdoaishdoaishdoaishdoaihdoaishdoaishdoasihdoasidhoasihd</p>
</div>
<div class="commitment">
<p>Alex 1:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 2:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 3:</p>
<p>He's works great.</p>
</div>
<div class="commitment">
<p>Alex 4:</p>
<p>He's works great.</p>
</div>
</div>