2つのdivをスタイル "col2"と並べて表示します。 これら2つのdivを水平に整列させたいと思います。 今日私は1つの列しか持っていないときはうまく動作しますが、2 divを横に並べると、divは中央に配置されません。親に2つのdivを並べて並べます
IMG
HTML
<div class="secondGroup">
<div class="col2">
<p class="titleSection">test 1</p>
<hr />
</div>
<div class="col2">
<p class="titleSection">test 2</p>
<hr />
</div>
</div>
CSS
.secondGroup {
text-align: center;
margin-top: 40px;
margin-bottom: 40px;
overflow: auto;
}
.col2 {
float: left;
width: 46.3%;
height: 350px;
background: white;
}
.col2:last-child {
margin-left: 40px;
}
.col2 .title {
float: left;
margin-left: 20px;
font-size: 14px;
}
を右の2番目のdivは最初のdivの下にはありません。 – wawanopoulos
@wawanopoulosそれは '.col2:last-child { margin-left:40px; } ' – ketan
' .col2:last-child'と同じ結果を削除します – wawanopoulos