1. 程式人生 > >CSS樣式連結和文字常用屬性

CSS樣式連結和文字常用屬性

行內: <div style="color:red;"></div>

內嵌<style>div{background-color:red;}</style>

外部引用

<link rel="stylesheet"(樣式表) href="./xxx.css">

 xxx.css檔案:  div{color:red}

CSS文字屬性

color : #999999; /*文字顏色*/

font-family : 宋體,sans-serif; /*文字字型*/

font-size : 9pt; /*文字大小*/

font-style:itelic; /*文字斜體*/

font-variant:small-caps; /*小字型*/

letter-spacing : 1pt; /*字間距離*/

line-height : 200%; /*設定行高*/

font-weight:bold; /*文字粗體*/

vertical-align:sub; /*下標字*/

vertical-align:super; /*上標字*/

text-decoration:line-through; /*加刪除線*/

text-decoration: overline; /*加頂線*/

text-decoration:underline; /*加下劃線*/

text-decoration:none; /*無修飾線*/

text-transform : capitalize; /*首字大寫*/

text-transform : uppercase; /*英文大寫*/

text-transform : lowercase; /*英文小寫*/

text-align:right; /*文字右對齊*/  

text-align:left; /*文字左對齊*/

text-align:center; /*內部元素居中*/

text-align:justify; /*文字分散對齊*/

vertical-align:top; /*垂直對齊該行元素內的最大元素頂部/

vertical-align:bottom; /*垂直對齊該行元素內的最大元素的底部*/

vertical-align:middle; /*垂直居中對齊*/

vertical-align:text-top; /*垂直對齊父元素的頂部*/

vertical-align:text-bottom; /*垂直對齊父元素的底部*/

top、bottom、text-top、text-bottom區別:

 

 

<p style="font-size: 15px; text-decoration: overline ;">一個

              <top>top對齊</top>

              <span style="font-size: 30px; text-decoration: overline;">方式</span>

         </p>

         <p style="font-size: 15px; text-decoration: overline ;">一個

              <ttop>text-top對齊</ttop>

              <span style="font-size: 30px; text-decoration: overline;">方式</span>

         </p>

         <p style="font-size: 15px; text-decoration: overline ;">一個

              <bottom>bottom對齊</bottom>

              <span style="font-size: 30px; text-decoration: overline;">方式</span>

         </p>

         <p style="font-size: 15px; text-decoration: overline ;">一個

              <tbottom>text-bottom對齊</tbottom>

              <span style="font-size: 30px; text-decoration: overline;">方式</span>

         </p>

 

執行結果:

overflow:hidden;//隱藏文字溢位部分。

white-space:nowrap;//對文字不換行。

text-overflow:ellipsis;//溢位部分用省略表示(基於前兩個屬性都有的情況下)

text-overflow:clip;//剪下。

text-overflow:".....";//自定義格式。

position:absolute;//設定文件的位置為絕對定位,relative表示相對定位。

right:50px;//表示該元素距離右邊元素的距離為50px,使用該元素必需設定position元素。

z-index;/*指定元素的堆疊順序*/

clip:rect(top,right,bottom,left);/*剪下圖形*/

flex//flex佈局,在使用flex佈局的時候,需要將父容器的flex的display設定為“display:flex;”。

title:"提示資訊“   title元素用在指定的元素上,會出現提示資訊。