Detailed description of the hight attribute in CSS, detailed explanation of the hight attribute in CSS

Source: Internet
Author: User

Detailed description of the hight attribute in CSS, detailed explanation of the hight attribute in CSS

Directory structure:

Contents structure [-]
  • References
  • Hight 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.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.