那是我的笔: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这个? –