What do you know about Min-height?

Source: Internet
Author: User

Sometimes we want to set the height of Div 100%. You are more careful when using Min-Height: 100%. However, this may cause a problem.

When the parent height is Min-Height: 100%, the sub-Min-Height: 100% is no longer 100%. Only the parent height is height: 100%, and the sub-Min-height is 100%.

 1   <!  Doctype html  >  2   <  Html  >  3       <  Head  >  4           < Meta  Charset  = "UTF-8"   />  5           <  Title  > PPT </  Title  >  6           <  Script  Type  = "Text/JavaScript"  SRC = "Http://code.jquery.com/jquery-1.7.2.min.js"  > </  Script  >  7           <  Style  Type  = "Text/CSS"  >  8   HTML, body  {  9   Height :  100%  ;  10   Width  :  100%  ;  11   Margin  :  0 ;  12   Padding  :  0  ;  13               }  14   #  {  15   Min-Width :  100%  ;  16   Min-height  :  100%  ;  17               }  18   # B  { 19   Min-height  :  100%  ;  20   Min-Width  :  100%  ;  21               }  22          </  Style  >  23       </  Head  >  24       <  Body  >  25           <  Div  ID  = ""  >  26              <  Div  ID  = "B"  >  27   Test  28               </  Div  >  29           </  Div  >  30       </  Body >  31   </  Html  > 

The result is that a is full and B is not.

Changed to this:

 1   <!  Doctype html  >  2   <  Html  >  3       <  Head >  4           <  Meta  Charset  = "UTF-8"   />  5           <  Title  > PPT </  Title  >  6           <  Script Type  = "Text/JavaScript"  SRC  = "Http://code.jquery.com/jquery-1.7.2.min.js"  > </  Script  >  7           <  Style  Type  = "Text/CSS"  >  8   HTML, body {  9   Height  :  100%  ;  10   Width  :  100%  ;  11  Margin  :  0  ;  12   Padding  :  0  ;  13               }  14  #  {  15   Width  :  100%  ;  16   Height  :  100%  ; 17               }  18   # B  {  19   Min-height  :  100%  ;  20   Min-Width  : 100%  ;  21               }  22           </  Style  >  23       </  Head  >  24       <  Body  > 25           <  Div  ID  = ""  >  26               <  Div  ID  = "B"  >  27   Test  28               </  Div  > 29           </  Div  >  30       </  Body  >  31   </  Html  > 

Result A and B are full.

If you do not set 100%, but set pixels, no problem. Therefore, it is better to use less Min-height.

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.