Detailed description of the hight attribute in CSS, detailed explanation of the hight attribute in CSS
Directory structure:
Contents structure [-]
ReferencesHight attribute value type list
| Value |
Describtion |
| Auto |
Default |
| Length |
Absolute Length |
| % |
Relative Length |
| Inherit |
Inheritance |
Here I mainly introduce the usage of relative length. For details about absolute length, refer to CSS size unit px % em rem for more information.
Definition of the % value of height:
This value is a percentage based on the percentage of its block-level elements.
Instance:
<!DOCTYPE html>
In Chrome, you can press "F12" and select "element" to view the information. The height of <div> is exactly 50% of the parent element <body>.
Note:
In the preceding example, the relative value of height is verified. However, you must note that if the parent element does not define hight, the hight percentage of the child element does not work. The height value is equivalent to the auto value unless it is changed by the absolute value. Here, hight does not mean that height is not written at all, which is different from defining height as 0px. You can try the following code:
<body id="b" style="width:0px;height:0px;"><br><div id="er" style="width:50%;height:50%;border:1px solid red;"></div>
Remove the style attribute of the body and try again.
<body id="b">
References:
Http://www.runoob.com/cssref/pr-dim-height.html
This blog is the original work of the blogger. If you need to reprint the original work, please indicate the source.