First, the difference
The difference is reflected in the child element inheritance, as follows:
- The parent element setting line-height:1.5 is directly inherited to the child element, and the child element calculates its own line-height according to its own font-size.
- The parent element setting line-height:150% is the calculation of the Line-height value, and then the calculated value to the child element inheritance, child element inheritance to get is the final value. When the child element is set font-size it has no effect on its line-height.
Ii. Examples
such as the parent element setting property: Font-size:14px;line-height:1.5,child set font-size:26px;
Then the parent element: Line-height = 14px * 1.5 = 21px, child element: Line-height = 26px * 1.5 = 39px.
Parent Element Setting Property: Font-size:14px;line-height:150%,child set font-size:26px;
Then the parent element: Line-height = 14px * 150% = 21px, child element: Line-height = Line-height = 21px of the parent element.
<!DOCTYPE HTML><HTML> <MetaCharSet= "Utf-8"/><Head> <title></title> <styletype= "Text/css">. Father{width:400px;Border:1px solid Pink;Display:Inline-block;}. Son{width:350px;Border:1px solid Green;}. Father1{font-size:14px;Line-height:1.5;}. Son1{font-size:26px;}. Father2{font-size:14px;Line-height:150%;}. Son2{font-size:26px;}</style></Head><Body> <Divclass= "Father Father1">parent element font-size:14px;line-height:1.5; calculated value is 21px<Divclass= "Son son1">The child element Font-size:26px;line-height inherits 1.5 of the parent element, and the computed value is 39px</Div> </Div> <Divclass= "Father Father2">parent element font-size:14px;line-height:150%; calculated value is 21px<Divclass= "Son son2">child elements font-size:26px;line-height= the line-height=21px of the parent element</Div> </Div></Body></HTML>
The author starof, because the knowledge itself in the change, the author is also constantly learning and growth, the content of the article is not updated regularly, in order to avoid misleading readers, convenient tracing, please reprint annotated source: http://www.cnblogs.com/starof/p/4742323. HTML has a problem welcome to discuss with me, common progress.
The difference between line-height1.5 and line-height:150%