css中auto什么意思-LMLPHP

本文操作环境:windows7系统、HTML5&&CSS3版、Dell G3电脑。

css里的auto是什么意思?

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,左右边距自动适应宽度相等。

更多详细的HTML/CSS知识,请访问CSS视频教程栏目!

以上就是css中auto什么意思的详细内容,更多请关注Work网其它相关文章!

09-07 18:26