ほとんどの人がそうしているように、私はdivをdivに分割しています。DIV内のDIVを正しく整列する方法
HTMLが明らかなエラーから自由に思える:
.caption{
width: 100%;
position: static;
}
.caption_left{
position: static;
width: 65%;
background-color: #CDCDC1;
padding: 2px;
vertical-align: top;
}
.caption_right {
float: right;
width: 35%;
background-color: white;
vertical-align: top;
}
<h4>[2. Previous]</h4>
<div class="caption">
<div class="caption_left">
Left Material
</div>
<div class="caption_right">
Right Material
</div>
</div>
<p>Some other stuff</p>
<h4>[3. Following]</h4>
私は何がうまくいかないのか分からない。私はこれを前にやったことがあり、うまくいきました。
。なぜ、何が間違っていたのか? –
@KenIngramあなたは 'caption-left'ブロック要素を持っています。これは設定された幅に関係なく全幅を取るでしょう。それを 'float'にすることは、それをウェブページの流れの一部として残し、残りのスペースをそのスペースに調整する他のフロート要素に残します。 –
入手しました。ありがとう。 –