CSS 中 auto 是什么意思?
CSS 中的 auto 是自动适应的意思, 而在 CSS 中 auto 往往都是默认值, 比如元素的 height 属性, 默认值就是 auto, 意思是高度自适应.
再比如:
margin:0 auto
意思是上下边距为 0, 左右边距为 auto, 就是自动适应.
但是, 如果要使用他的话, 就必须给标签配上指定的宽度, 如下:
- <div class="center"> 居中 </div>
- <style type="text/css">
- .center{
- width:200px;
- height:200px;
- margin:0 auto;
- background-color:yellow;
- }
- </style>
另外, margin:0 auto 和 margin: 0 auto 0 auto 的效果是相同的. 都是指的上下边距为 0, 左右边距自动适应宽度相等.
来源: http://www.css88.com/qa/css3/16091.html