Vertical-align's understanding

Source: Internet
Author: User


<div class= "Temp" >
<div class= "Juzhong" >fagagagagag</div>
<div class= "Demo" >xxxxxxxxxxx</div>
</div>
The CSS is as follows:
. juzhong{
background:red;
line-height:60px;
Display:inline-block;
}
. demo{
Background:green;
height:90px;
Display:inline-block;
Vertical-align:middle;
}
------------------
<div class= "Juzhong" >fagagagagag</div>
<div class= "Demo" >xxxxxxxxxxx</div>
<div class= "XX" ><div>ddafafjklj</div></div>
CSS-------
. juzhong{
background:red;
line-height:60px;
Display:inline-block;
}
. demo{
Background:green;
height:90px;
Display:inline-block;
Vertical-align:middle;

}
. xx{
Background:blue;
height:200px;
Vertical-align:middle;
Display:inline-block;
}


After experimentation, the conclusion is that the first Div must be set to Line-height, and the other settings display and vertical-align.

If you add a height:300 to the first Div, the effect is as follows

is still centered on the line height standard. The height of the box is not the baseline.

If you add a line-height to the second box, it changes the line number of the text element in the box, and the other remains unchanged.
Remove height, change the height of the box, and still center the alignment.
If Vertical-align is set to bottom, it is aligned at the bottom of the positive row height.

Vertical-align's understanding

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.