のすべての要素を中央に配置する必要がありますdiv.to_left_60
。そこにあるすべての要素に対して機能するソリューションが必要です。text-align: center
この目的のために設定しました。テキストでは機能しますが、私の ul 要素では機能しません。マージン とabsolute/relative
で遊んでみましたが、うまくいきませんでした。
ul.problem は、この div の中央に配置する必要がある要素です。jsfiddle から、白い背景が中央に配置されていないことがわかります。
HTML
<div class="to_left_40">gtestsetes</div>
<div class="to_left_60">
<p>gtestsetes</p>
<img src="https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcTvZsT7cLwPFCC0joFhZoi6OylhGaIVHBPYn--PrH3nzZdMwH0grA" width="265px" />
<ul class="problem">
<li>fsfsd</li>
<li>fsfsd</li>
</ul>
<ul>
<li>fsfsd</li>
<li>fsfsd</li>
</ul>
CSS
ul {
list-style: none;
text-align: justify;
background-color: yellow;
}
ul.problem li {
list-style-type: none;
display: block;
width: 245px;
height: 164px;
padding: 14px 10px 0 10px;
background-color: white;
background-repeat: no-repeat;
text-align: center;
font-size: 18px;
}
.to_left_40 {
float: left;
width: 40%;
background-color: red;
}
.to_left_60 {
float: left;
width: 60%;
background-color: green;
text-align: center;
}
JSFiddle: http://jsfiddle.net/qVTQ4/
編集:(ソリューション)
これは次のことに役立ちます。
ul.problem li{margin:0 auto;}
このソリューションを変更しました:
.to_left_60 * {
margin:0 auto;
}