CSS中的AUTO怎么理解

html-css014

CSS中的AUTO怎么理解,第1张

自动。高度自动根据需要来限制高度,eg:{overfloat:auto}表示高度根据需要会自己增加。

在margin中表示自动居中,eg:#abc{margin:0 auto;}表示abc这个DIV自动居中,当然这样写可恶的IE6中是不能居中的,所以要做到兼容就必须在其中加入text-align:center这个属性。

css中的auto是自动适应的意思,而在css中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,左右边距自动适应宽度相等。