1. 程式人生 > >CSS文本常用樣式

CSS文本常用樣式

proc itl col css title img 51cto ges 縮進

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>

技術分享圖片

CSS文本常用樣式