当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


CSS min-height用法及代码示例


CSS中的min-height属性用于设置元素的最小高度。如果元素的内容小于min-height,则使用min-height属性;如果元素的内容大于min-height,则该属性无效。此属性确保height属性的值不小于所考虑元素的指定min-height值。

用法:

min-height:length|initial|inherit; 

属性值:


  • length:此属性用于设置min-height。长度的默认值是0。高度可以设置为px,%,cm等形式。

    用法:

    min-height:length;

    例:

    <!DOCTYPE html> 
    <html> 
        <head> 
            <title> 
                min-height property 
            </title> 
              
            <style> 
                p { 
                    min-height:10px; 
                    border:1px solid black; 
                } 
            </style> 
        </head> 
        <body> 
            <p> 
                Prepare for the Recruitment drive of product 
                based companies like Microsoft, Amazon, Adobe 
                etc with a free online placement preparation 
                course. The course focuses on various MCQ's  
                & Coding question likely to be asked in the 
                interviews & make your upcoming placement  
                season efficient and successful. 
            </p> 
        </body> 
    </html>                    

    输出:
    min height

  • initial:它用于将min-height属性的值设置为其默认值。

    用法:

    min-height:initial;

    例:

    <!DOCTYPE html> 
    <html> 
        <head> 
            <title> 
                min-height property 
            </title> 
              
            <style> 
                p { 
                    min-height:initial; 
                    border:1px solid black; 
                } 
            </style> 
        </head> 
        <body> 
            <p> 
                Prepare for the Recruitment drive of product 
                based companies like Microsoft, Amazon, Adobe 
                etc with a free online placement preparation 
                course. The course focuses on various MCQ's  
                & Coding question likely to be asked in the 
                interviews & make your upcoming placement  
                season efficient and successful. 
            </p> 
        </body> 
    </html>                    

    输出:
    min height

  • inherit:此属性是从其父级继承的。

支持的浏览器:下面列出了min-height属性支持的浏览器:

  • 谷歌浏览器1.0
  • Internet Explorer 7.0
  • Firefox 3.0
  • Safari 2.0.2
  • Opera 4.0


相关用法


注:本文由纯净天空筛选整理自EnaMotwani大神的英文原创作品 CSS | min-height Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。