CSS 1.css介绍 css指的是层叠样式表(cascading style sheets) 官方文档:https://www.w3school.com.cn/css/index.asp为什么需要c
顺晟科技
2022-09-13 13:49:41
50
1、顶线、中线、基线、底线
基线?这是什么东西?听都没听过!我们都用过英文簿,英文簿每一行都有4条线,这4条线分别是:(1)顶线;(2)中线;(3)基线;(4)底线。
在CSS中,每一行文字可以看成一个“行盒子”,而每一个行盒子都有4条线:(1)顶线;(2)中线;(3)基线;(4)底线。没错,这4条线跟英文簿中的4条线是一样的道理。2、行高、行距与半行距
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <style type="text/css"> div { width:240px; height:60px; border:1px solid gray; font-size:12px; text-align:center; } #div1{line-height:20px;} #div2{line-height:40px;} #div3{line-height:60px;} </style></head><body> <div id="div1">height为50px,line-height为20px</div> <div id="div2">height为50px,line-height为40px</div> <div id="div3">height为50px,line-height为60px</div></body></html>
举例:
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head> <title></title> <style type="text/css"> body{font-size:30px;} #outer-box { /*父元素行高:30px×150%=45px*/ line-height:150%; background-color:Red; color:White; } #inner-box { /*子元素行高:30px×150%=45px(继承父元素的line-height)*/ font-size:20px; background-color:Purple; color:White; } </style></head><body> <div id="outer-box">这是父元素 <div id="inner-box">这是子元素</div> </div></body></html>
09
2022-11
09
2022-11
09
2022-11
09
2022-11
19
2022-10
19
2022-10