那是我的筆:http://codepen.io/helloworld/pen/oxgqpJ以無邊距的最大寬度居中放置div:auto;
我想中心一個div固定的最大寬度,但是當我固定的最大寬度下,我想10%的每一側的邊緣,因爲此刻沒有該解決方案領域的可見邊際。
的缺點是會佔用每邊有10%的保證金股利不居中了它開始在左側......
我怎樣才能解決呢?
<div id="container">
Center me with a fixed max width, but when I am under the fixed max width I want a margin of 10% on each side , because at the moment there is no visible margin.
</div>
#container
{
margin: 0 auto;
// use instead in smaller resolutions
//margin: 0 10%;
max-width:1024px;
background:orange;
}
你想水平或垂直居中。你的預期產出是多少? – ketan
因此水平居中margin:0 auto; – Elisabeth
http://codepen.io/anon/pen/wGBmNz這個? –