8.11 CSS知識點4

來源:互聯網
上載者:User

標籤:

邊框樣式1.邊框寬度

border-width:medium | thin | thick | length

border-top-width  設定上邊框寬度

border-bottom-width  設定下邊框寬度

border-left-width  設定左邊框寬度

border-right-width  設定右邊框寬度

例:

div{    width:300px;    height:100px;    border-style:solid;    border-width:1px;}
2.邊框顏色

border-color:color

border-top-color  設定上邊框顏色

border-bottom-color  設定下邊框顏色

border-left-color  設定左邊框顏色

border-right-color  設定右邊框顏色

例:

div{    width:300px;    height:100px;    border-style:solid;    border-width:1px;     border-color:#ff0000;      }
3.邊框線

border-style:none | hidden | dotted | dashed | solid | double | groove | ridge | inset  | outset

border-top-style     設定上邊框線

border-bottom-style     設定下邊框線

border-left-style     設定左邊框線

border-right-style     設定右邊框線

例:

div { width:300px; height:100px; border-style:solid; }

 

4.邊框樣式縮寫

border:border-width | border-style | border-color

例:

div {     width:300px;     height:100px;     border-style:solid;     border-width:1px;     border-color:#FF0000; }

縮寫後:

div {    width:300px;     height:100px;     border:1px solid #FF0000;}
5.圓角效果

border-radius:[<length>|<percentage>]{1,4}[/[<length>|<percentage>]{1,4}]

例:

所有角都使用半徑為10px的圓角

div{ border-radius:10px;} 

 四個半徑值分別是左上方、右上方、右下角和左下角,順時針

div{ border-radius: 5px 4px 3px 2px; }

也可以分別設定每個角的垂直半徑和水平半徑,用斜杠隔開,第一個參數表示左上方開始順時針的水平半徑,第二個參數表示左上方開始順時針的垂直半徑

div{ border-radius: 10px 20px 30px 40px  /  5px 10px 15px 20px; }

圓

div{ border-radius:50% }
6.邊框圖片

邊框樣式使用圖片來填充

border-image:<‘border-image-source‘> | <‘border-image-slice‘> [/<‘border-image-width‘>|/<‘border-image-width‘>/<‘border-image-outset‘>] | <‘ border-image-repeat‘>

注意:

border-image-slice :是一個數值或百分比,不需要帶單位(特指px)設定了border-image之後,border-style則不顯示

例:

.test { border: 10px solid gray; border-image: url(test.png) 10/10px; }
7.盒子陰影

box-shadow是向盒子添加陰影,支援添加一個或多個

使用方法:

box-shadow: X軸位移量 Y軸位移量 [陰影模糊半徑] [陰影擴充半徑]  [陰影顏色] [投影方式];

例:

外陰影常規效果

.outset { box-shadow: 5px 5px rgba(0, 0, 0, .6); }  

外陰影模糊外延效果

.outset-blur{ box-shadow: 5px 5px 5px 10px rgba(0, 0, 0, .6); }

內陰影製作效果

. inset { box-shadow: 2px 2px 5px 1px rgba(0, 0, 0, .6) inset; }
段落樣式1.行高

控制段落內每行高度

line-height:normal | length

例:

p { line-height:25px;}p { line-height:150%}
2.段落縮排

控制段落的首行縮排

text-indent:length

例:

p { text-indent:2em;}
3.段落對齊

控制段落對齊,不但是文本,對象中的其它inline或inline-block元素也能夠被text-align進行對齊的設定。

text-align:left | right | center | justify

例:

p { text-align:right;}p { text-align:center;}
4.文字間距

控制段落的文字間的距離

letter-spacing:normal | length

例:

p { letter-spacing:5px;}
5.文字溢出

控制文字內容溢出部分的樣式

text-overflow:clip | ellipsis

值 描述
clip 當內聯內容溢出塊容器時,將溢出部分裁切掉
ellipsis 當內聯內容溢出塊容器時,將溢出部分替換為(...)

 

 

 

注意:

text-overflow只是用來解說文字溢出時用什麼方式顯示,要實現溢出時產生省略符號的效果,還須定義強制文本在一行內顯示(white-space:nowrap)及溢出內容為隱藏(overflow:hidden),只有這樣才能實現溢出文本顯示省略符號的效果。

例:

div.input{    overflow:hidden;    white-space:nowrap;    text-overflow:ellipsis;}
6.段落換行

控制內容超過容器的邊界時是否斷行

word-wrap:normal | break-word

值 描述
normal 允許內容頂開或溢出指定的容器邊界
break-word 內容將在邊界內換行,如果需要,單詞內部允許斷行

 

 

 

例:

p {word-wrap: break-word;}
背景樣式1.背景顏色

background-color : transparent | color

例:

body { background-color:#ccc;}h1 { background-color:#ededed;}
2.RGBA

RGB是一種色彩標準,是由紅(R)、綠(G)、藍(B)的變化以及相互疊加來得到各式各樣的
顏色。RGBA是在RGB的基礎上增加了控制alpha透明度的參數。


color:rgba(R,G,B,A)以上R、G、B三個參數,正整數值的取值範圍為:0 - 255。百分數值的
取值範圍為:0.0% - 100.0%。超出範圍的數值將被截至其最接近的取值極限。並非所有瀏覽
器都支援使用百分數值。A為透明度參數,取值在0~1之間,不可為負值。

 例:

border-color:rgba(255 , 0 , 0 , .7);background-color:rgba( 100 , 120 , 60 , .5 );border-color:rgba(255 , 0 , 0 , .7);
3.漸層色彩

CSS3 Gradient 分為線性漸層(linear)和放射狀漸層(radial)。由於不同的渲染引擎實現漸層的文法不同,這裡我們只針對線性漸層的 W3C 標準文法來分析其用法,其餘大家可以查閱相關資料。W3C 文法已經得到了 IE10+、Firefox19.0+、Chrome26.0+ 和 Opera12.1+等瀏覽器的支援。

角度 英文 作用
0deg to top 從下向上
90deg to right 從左向右
180deg to bottom 從上向下
270deg to left 從右向左
  to top left 右下角到左上方
   to top right 左下角到與右上方

 

 

 

 

 

 

 

例:

background-image:linear-gradient(to left, red 30%,blue);
4.背景圖片

background-image:none | url( url )

例:

body { background-image:url(images/bg.gif);}
5.背景平鋪方式

background-repeat : repeat | no-repeat | repeat-x | repeat-y

例:

body { background-repeat:repeat-x;}    
6.背景定位

background-position : 靠左對齊方式  上對齊

例:

body { background-position:left bottom;}body { background-position:30% 20px;} 

 

8.11 CSS知識點4

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.