難以解釋我想要什麼,所以我會展示我想要的結果(在Photoshop中製作)和我的代碼在js中的動畫gif發生了什麼。「Center left」與css對齊
正如你可以看到,當藍框的大小是不夠的,適合在一排的所有項目中,4º項目被移動到第二行(如預期),但而不是在對齊中心,他左對齊。
我的CSS代碼
.outer-box
{
background: #00cc99;
width: 100%;
max-width: 800px;
font-size: 0;
text-align: center;
padding: 10px;
}
.outer-box a
{
display: inline-block;
width: 120px;
height: 80px;
padding: 10px;
background: #ff5050;
font-size: 12px;
}
.outer-box a:hover
{
background: #990000;
}
.outer-box a div
{
background: #99ccff;
width: 100%;
height: 100%;
}
我的HTML
<div class="outer-box">
<a href="#"><div>I put image and text here</div></a>
<a href="#"><div>I put image and text here</div></a>
<a href="#"><div>I put image and text here</div></a>
<a href="#"><div>I put image and text here</div></a>
</div>
我試圖用浮動的div(外箱內一個DIV和使用浮動左邊的鏈接元素),但沒有成功發揮。
有沒有辦法做到這一點,沒有JavaScript?
這是我的代碼jsFiddle。
PS。英語不是我的母語' - '。
您好大衛,該'A'元件是左對齊,因爲我想,問題是'內框'需要在'外框'的中心。 [像這樣](http://s11.postimg.org/odr77iiwj/result_2.jpg) – Kirito94