CSS基礎(chǔ)教程之尺寸、字體及文本屬性
CSS尺寸屬性
width:元素寬度,一定要加px單位。
height:元素高度。
CSS字體屬性
font-size:文字大小。如:font-size:14px;
font-family:字體。如:font-family:微軟雅黑;
font-style:斜體,取值:italic。如:font-style:italic;
font-weight:粗體,取值:bold。如:font-weight:bold;
CSS文本屬性
color:文本顏色
text-decoration:文本修飾線,取值:none(無)、underline(下劃線)、overline(上劃線)、line-through(刪除線)
text-align:文本水平對齊方式,取值:left、center、right
line-height:行高,可以用固定值,也可以用百分比。如:line-height:24px; ??line-height:150%;
text-indent:首行縮進(jìn)。如:text-indent:28px;
letter-spacing:字間距。
實(shí)例如下
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>php.cn</title> <style type="text/css"> h1{ color:red; width:350px; text-align:center; font-family:微軟雅黑; } p{ line-height:150%; text-indent:28px; font-family:楷體; } .box{ font-style:italic; font-weight:bold; text-decoration:underline; } </style> </head> <body> <h1>習(xí)近平心中的互聯(lián)網(wǎng)</h1> <p>互聯(lián)網(wǎng)是20世紀(jì)最偉大的發(fā)明,它正在將人類“<span class="box">一網(wǎng)打盡</span>”,人們在不知不覺中已經(jīng)融入了互聯(lián)網(wǎng)生態(tài),互聯(lián)網(wǎng)讓世界變成了“雞犬之聲相聞”的地球村。</p> </body> </html>