當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。