JavaScript--html tag precautions review summary

1. What is the difference between height: auto and height: 100%?

auto是自适应,是随内容的高度而撑开的。100%是根据父级元素的高度来决定的

<div style="height:auto;width:100px;float:left;">
这个容器的高度是随里面的内容的高度而定</div>

<div style="height:100%;width:100px;float:right;">
这个容器的高度为父级的高度,100px</div> </div>


2. What does the value of the auto attribute of an element in CSS mean, for example, what does margin: 0 auto mean?

auto 你可以理解为一种 自动/自适应 的概念 比如 现在项目需要一个宽度为960px的整体布局居中 
根据用户浏览器大小不同你将需要使用margin:0 auto;来实现。无论用户浏览器宽度为多少

margin:0 auto,意思就是上下边距为0,左右边距为auto,就是自动适应。
但是,如果要使用他的话,就必须给标签配上指定的宽度


3. Set the font

font:60px/60px "simhei";
的意思是字体大小为60 行高60 字体为黑体


4.no-repeat

background: yellow url("img/3.jpg") no-repeat
css中no-repeat一般用在元素backgroud-repeat的设置中,含义为不平铺;


5.overflow hidden

<!DOCTYPE html>  
<html>  
<head>  
    <title>父元素中有overflow:hidden, 子元素absolute不能显示</title>  
    <style>  
        .parent{  
            height:40px;  
            width:200px;  
            border:solid 1px black;  
            position:relative;  
        }  
        .sub{  
            position:absolute;  
            top:10px;  
            left:10px;  
            height:100px;  
            width:100px;  
            background-color:red  
        }  

        .overHidden{  
            overflow:hidden;    /* 同样会隐藏position:absolute的子元素 */  
        }  
    </style>  
</head>  
<body>  
这个是有overflow:hidden  
    <div class="parent overHidden">  
        <div class="sub"></div>  
    </div>  
    这个没有  
    <div class="parent">  
        <div class="sub"></div>  
    </div>  
</body>  
</html>  

write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325670537&siteId=291194637