CSS:不可思議的border屬性

來源:互聯網
上載者:User

標籤:des   style   blog   http   io   color   ar   os   使用   

原文:Magic of CSS border property

譯文:不可思議的CSS border屬性

譯者:dwqs

在CSS中,其border屬性有很多的規則。對於一些事物,例如三角形或者其它的映像,我們仍然使用圖片代替。但是現在就不需要了,我們可以用CSS形成一些基本圖形,我分享了一些關於這方面的技巧。

1、正三角形:

.triangle_up{  height:0px; width:0px;  border-bottom:50px solid #006633;  border-left:50px solid transparent;  border-right:50px solid transparent;}

 

2、倒三角形:

.triangle_down{  height:0px; width:0px;  border-top:50px solid #006633;  border-left:50px solid transparent;  border-right:50px solid transparent;}

 

3、左三角形

.triangle_left{  height:0px; width:0px;  border-left:50px solid #006633;  border-top:50px solid transparent;  border-bottom:50px solid transparent;  float:left;}

 

4、右三角形

.triangle_right{  height:0px; width:0px; float:left;  border-right:50px solid #006633;  border-top:50px solid transparent;  border-bottom:50px solid transparent;}

 

5、十字街效果

.crossSquare{  height:0px; width:0px;  border-right:50px solid blue;  border-top:50px solid gray;  border-bottom:50px solid red;  border-left:50px solid yellow;}

 

1至5的demo示範(為了示範方便,對原始碼改動了一下):http://jsfiddle.net/rt8cjtwq/embedded/result/

6、方向箭頭(突出效果,改動了原始碼)

CSS:

.triangle_left{  height:0px; width:0px;  border-left:50px solid #006633;  border-top:50px solid transparent;  border-bottom:50px solid transparent;  /*float:left;*/}.triangle_right{  height:0px; width:0px; /*float:left;*/  border-right:50px solid #006633;  border-top:50px solid transparent;  border-bottom:50px solid transparent;}
HTML:
<div class="arrow">  <div class="triangle_right"></div>  <div class="arrowLine"></div></div><div class="arrow">  <div class="arrowLine"></div>  <div class="triangle_left"></div></div>
效果:

     7、製作一個Delicious Logo:CSS:
.delociousLogo {   height:100px; width:100px; } .topleft {   height:0px; width:0px;   border-top:50px solid #FFFFFF;   border-right:0px solid #FFFFFF;   border-bottom:0px solid #FFFFFF;   border-left:50px solid #FFFFFF;   float:left; } .topright {   float:left;   height:0px; width:0px;   border-top:50px solid #0000CC;   border-right:0px solid #0000CC;   border-bottom:0px solid #0000CC;   border-left:50px solid #0000CC; } .bottomleft {   float:left;   height:0px; width:0px;   border-top:50px solid #000000;   border-right:0px solid #000000;   border-bottom:0px solid #000000;   border-left:50px solid #000000; } .bottomright {   float:left;   height:0px; width:0px;   border-top:50px solid #999999;   border-right:0px solid #999999;   border-bottom:0px solid #999999;   border-left:50px solid #999999; }

 

HTML:
<div class="delociousLogo">  <div class="topleft"></div>  <div class="topright"></div>  <div class="bottomleft"></div>  <div class="bottomright"></div></div>

 

效果:(左上方的邊框顏色是白色)

推薦文章:重溫CSS:Border屬性


下一篇:8個很有用的PHP安全函數,你知道幾個?

CSS:不可思議的border屬性

聯繫我們

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