line-height:150%和line-height:1.5的區別,line-height150%
line-height:150%和line-height:1.5的區別
"%":是繼承父級元素的距離;
"無單位":是子項目計算各自的行距離 eg:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>body{font-size:14px;line-height:150%;background: black;}p{font-size:26px;background: gray;color: white;}</style></head><body><p>你好!</p></body></html>
效果
1、當line-height:XX%時:body{font-size:14px;line-height:150%;}p{font-size:26px;}結果就是:body{line-height:21px;}//14*150%=21p{line-heigt:21px;}//繼承父元素 eg:
<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title><style>body{font-size:14px;line-height:1.5;background: black;}p{font-size:26px;background: gray;color: white;}</style></head><body><p>你好!</p></body></html>
效果
2、當line-height:X.X時:body{font-size:14px;line-height:1.5;}p{font-size:26px;}結果就是:body{line-height:21px;}//14*1.5=21p{line-height:39px;}//26*1.5=39