html - Questions about the value of width and height attributes in CSS
我想大声告诉你
我想大声告诉你 2017-06-27 09:19:17
0
2
745
 疑问1:
    
在w3cschool中查看width和height属性,可以发现它们的默认值都是auto,

当width或height的属性值设置为auto时,浏览器会计算出实际的高度是什么意思?
    下面是height的属性取值:  

疑问2:
在下面的例子中,这个p盒子中没有设置width和height属性,那它的宽和高是由什么决定的

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>width和height</title>
    <style type="text/css">
        .p1{
            border: 2px solid skyblue;
        }
    </style>
</head>
<body>
    <p class="p1">
        这里有些内容
    </p>
</body>
</html>
我想大声告诉你
我想大声告诉你

reply all(2)
漂亮男人

See:
https://stackoverflow.com/que...
http://blog.csdn.net/wgw33536...

ringa_lee

The calculation of width and height is very deep, and a chapter is dedicated to the standardization.

In the example, because p is a block-level element, its width is the width of the content box of the body minus the left and right borders of 4px.
The height is determined by the text inside, that is, by line-height and font-size (when line-height is a ratio).

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!