CSS基礎篇之選擇符3

來源:互聯網
上載者:User

標籤:

border(邊框)

如何用CSS調出邊框

我們給p標籤加一個邊框試一下

 

p{    border:1px  solid   #ccc;/*這是縮寫*/}

 

第一個值是為邊框的寬度

 第二個值是為邊框線樣式為直線

第三個值是為邊框的顏色

 

border-width(邊框的寬度)

 

 

 

如果不調寬度的話預設邊框是從左邊到最右邊。設定之後可以調節寬度。

 

border-top-width:;上

 

border-bottom-width:;下

 

border-left-width:;左

 

border-right-width:;右

 

 

 

border-style(邊框線樣式)

 

單個邊框線調節樣式

border-top-style:;(設定上邊框)

border-bottom-style:;(設定下邊框)

border-left-style:;(設定左邊框)

border-right-style:;(設定右邊框)

 

縮寫div{ width300px;height100px;border-style:solie;}

 

      寬度            高度             邊框樣式

其他邊框樣式值

none:無輪廓。border-color將被忽略,border-width計算值為0,除非邊框輪廓為映像,即border-image。

hidden:隱藏邊框。IE7及以下尚不支援

dotted:點狀輪廓。IE6下顯示為dashed效果

dashed:虛線輪廓。

solid:實線輪廓

double:雙線輪廓。兩條單線與其間隔的和等於指定的border-width值

groove:3D凹槽輪廓。

ridge:3D凸槽輪廓。

inset:3D凹邊輪廓。

outset:3D凸邊輪廓。

 

 

border-color(邊框顏色)

 

 

 

還可以設定單個邊的顏色

 

border-top-color:;上

 

border-right-color:;右

 

border-bottom-color:;下

 

border-left-color:;左

 

利用邊框做出三角箭頭

div{    width: 0;     height: 0;     border-top: 100px solid green;     border-left: 100px solid transparent;     border-right: 100px solid transparent;}

 

 

圓角效果

 

 

所有角的半徑為10px圓角矩形。

div{                width: 300px;                height: 300px;                background-color: black;                margin: 10px;                border-radius: 15px;/*上右左下*/            }

 

 

 

 

四個角的半徑分別為左上方順時針到左下角的半徑的。

div{                width: 300px;                height: 300px;                background-color: red;                margin: 10px;                border-radius: 10px 15px 20px 30px;}

 

 

 

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

div {                width: 300px;                height:300px;                background-color: green;                margin: 10px;                border-radius:40px  30px  20px  10px/5px  10px  15px  20px;            }

 

畫圓

div{    border-radius:50%}

 

 

豎著的半圓

div{    height: 300px;                background-color: yellow;                width: 150px;                border-radius: 150px 0 0 150px;/*寬是高的一半*/                margin: 10px;    }

 

橫著的半圓

div{                width: 300px;                background-color: yellowgreen;                height: 150px;                border-radius: 150px 150px 0 0;/*高是寬的一半*/            }

 

 

盒子陰影

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

 

外陰影常規效果

div{                width:100px;                height:100px;                background-color:#cccccc;                box-shadow: 5px 5px 20px #000000;                }

 

 

外陰影模糊外延效果

div{    width:100px;                height:100px;                background-color:#cccccc;                box-shadow:5px 5px 5px 20px #000000 ;            }

 

 

內陰影製作效果

div{                width:100px;                height:100px;                background-color:#cccccc inset;            }

 

 

 

雙內陰影製作效果

div{                width:100px;                height:100px;                background-color:#cccccc;                box-shadow:5px 5px 20px 2px #000000 inset,-2px -2px 5px 1px #ccc inset;            }

 

 

段落樣式

行高(line-height)

p{Width:300px;Height:500px;Line-height:150px;}

行高是指內容的寬度到文字頂部之間的距離就是行高。

 

段落縮排

 

P{Text-indent:em;}

 

 

從左往右縮排了一個字元的間隔。數量不要太多。

 

 

 

段落對齊

Text-align:left | right | center | justify;

P{Text-align:left;}

 

 

 

 

文字間距

Letting-spacing:間距長度;

P{Letting-spacing:10px;}

 

 

每個字都會有間距間距距離取決於你的間距長度大小

 

 

 

文字溢出

 

Text-overtlow:clip | ellipsis

 

Clip的表現出來的效果是文字溢出的部分才會隱藏

 

Ellipsis的表現出來的效果是文字溢出的部分全部以...表示

 

如何用ELlipsis如何?文字溢出時產生省略符號的效果需要用到whtie-space:nowrap;(不換行)

 

Overflow:hidden;(隱藏溢出的部分)

Div{width: 140px;                border: 1px solid #000;                white-space: nowrap;/*不換行*/                overflow: hidden;/*隱藏溢出於邊框部分*/        text-overflow: ellipsis/clip;}

我這裡加了一個邊框讓你們看的更清楚。

 

 

背景樣式

背景顏色

Background-color:transparent | color;(透明和顏色)

div{     Bakcground-color:#cccccc;}
Div{Background-color:transparent;}

 

背景圖片

Background-image:none | url

注意這個圖片插入要寫url。

Background-image:none | urlP{     Background-image:url(./圖片名);}

背景平鋪方式

Background-repeat:repeat | no-repeat | repeat-x| repeat-y

repeat:平鋪

P{Background-repeat:on-repeat;}

 

背景定位

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

No-repeat:不平鋪

X-repeat:從X軸開始平鋪

Y-repeat:從Y軸開始平鋪

P{     Background-color:right bottom;         }

 

CSS基礎篇之選擇符3

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.