CSS文字常用樣式
阿新 • • 發佈:2018-12-19
1.常用的應用文字的CSS樣式:
color設定文字的顏色
font-size 設定文字的大小,如font-size:12px
font-family 設定文字的字型,如font-family:‘微軟雅黑’
font-style 設定文字是否傾斜,如font-style:'normal',設定不傾斜,‘italic’設定文字傾斜
font-weight 設定文字是否加粗,如font-weight:bold,設定加粗,normal,不加粗
line-height 設定文字行高,相當於在每行文字上下同時加間距,line-height:24px
font 同時設定文字的幾個屬性,寫的順序有相容性問題,如下順序:font:是否加粗 字號/行高 字型,如:font:normal 12px/36px '微軟雅黑‘
text-decoration:underline 設定文字的下劃線,去掉:text-decoration:none
text-indent 設定文字首行縮排,如:text-indent:24px,只針對首行
text-align 設定文字的水平對齊方式,center,left,right,
程式碼
<head>
<meta charset="utf-8">
<title>常用文字樣式</title>
<style type="text/css">
div{ font-size: 30px; font-family: 'Microsoft Yahei'; font-style: italic; text-indent: 60px; } em{ font-style: normal; color: gold; } span{ font-weight: bold; line-height: 80px; text-decoration: underline; } a{ text-decoration: none; /*去掉a連結的下劃線*/ text-align: center; /*沒效果,a標籤的寬頻只有文字寬頻*/ } p{ text-align: center; } </style>
</head>