純CCS繪製三角形箭頭圖案

來源:互聯網
上載者:User

標籤:瀏覽器   str   實現   需要   javascrip   points   圖案   bottom   是你   

用CSS繪製三角形箭頭。使用純CSS,你只需要很少的代碼就可以創作出各種瀏覽器都相容的三角形箭頭!

 

CSS代碼:
/* create an arrow that points up */div.arrow-up {width: 0; height: 0; border-left: 5px solid transparent;  /* left arrow slant */border-right: 5px solid transparent; /* right arrow slant */border-bottom: 5px solid #2f2f2f; /* bottom, add background color here */font-size: 0;line-height: 0;}/* create an arrow that points down */div.arrow-down {width: 0; height: 0; border-left: 5px solid transparent;border-right: 5px solid transparent;border-top: 5px solid #2f2f2f;font-size: 0;line-height: 0;}/* create an arrow that points left */div.arrow-left {width: 0; height: 0; border-bottom: 5px solid transparent;  /* left arrow slant */border-top: 5px solid transparent; /* right arrow slant */border-right: 5px solid #2f2f2f; /* bottom, add background color here */font-size: 0;line-height: 0;}/* create an arrow that points right */div.arrow-right {width: 0; height: 0; border-bottom: 5px solid transparent;  /* left arrow slant */border-top: 5px solid transparent; /* right arrow slant */border-left: 5px solid #2f2f2f; /* bottom, add background color here */font-size: 0;line-height: 0;}

繪製這些三角形的關鍵在於,你要讓箭頭所指方向的兩個側邊有很粗的邊框。而背向箭頭方向的一邊也是同樣粗的邊框,而這條邊的顏色就是你的三角形的顏色。邊框越粗,三角形越大。用這種方法你可以繪製出各種顏色、各種大小、各種朝向的箭頭。最妙的是,你只需要幾行CSS代碼就能實現這種效果。

 

純CCS繪製三角形箭頭圖案

聯繫我們

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