關於html-三角的製作

來源:互聯網
上載者:User

標籤:border   三角形   層次感   製作   正方形   

因為最近看到別人寫的不錯的樣式,所以就想自己實現,但是呢用到了一個三角形,所以稍微研究一下。


效果是這樣的:


650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/86/B3/wKiom1fH3XKiCncXAAAIA7DN8hU876.png" title="triangle.png" alt="wKiom1fH3XKiCncXAAAIA7DN8hU876.png" />

注意是下邊那個淺色三角,感覺書籤的效果有木有。看著很有層次感。



接下來就是實現了,利用border這個屬性。


這裡的話主要是 border-top、border-left、border-right、border-bottom 可以在css手冊中查到(http://css.doyoe.com/)


先拉個空白寫吧,我把幾個屬性都寫上。

code:

.triangle{width:0;height:0;border-top:10px solid #000;border-left:10px solid #000;border-right:10px solid #000;border-bottom:10px solid #000;}

然後結果就是在螢幕上得到一個正方形的小黑塊。

650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/86/B3/wKioL1fH4EOBTxGaAAAFGTM7jcQ726.png" title="黑方塊.png" alt="wKioL1fH4EOBTxGaAAAFGTM7jcQ726.png" />


接下來就是實現三角了,需要使用transparent這個參數,這個參數是使顏色透明。


code:

.triangle{width:0;height:0;border-top:10px solid #000;border-left:10px solid #000;border-right:10px solid #000;border-bottom:10px solid transparent;}


效果:(有沒有書籤的感覺?這裡可以更改top的值,加長!)

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M00/86/B3/wKioL1fH4mHRiIbTAABqSfF5OSc868.png" title="透明三角.png" alt="wKioL1fH4mHRiIbTAABqSfF5OSc868.png" />


那現在我們需要的就是給left也加上一個transparent就可以了,但是注意一點,這個時候top和right的修改影響這個三角的大小,比如我們去掉一項,可以看效果。


650) this.width=650;" src="http://s4.51cto.com/wyfs02/M01/86/B3/wKiom1fH5BCiSh_gAABEe-GbM_A462.png" style="float:none;" title="右三角-1.png" alt="wKiom1fH5BCiSh_gAABEe-GbM_A462.png" />

650) this.width=650;" src="http://s4.51cto.com/wyfs02/M00/86/B3/wKioL1fH5BCh8IW1AABFOy436uk317.png" style="float:none;" title="有三角-2.png" alt="wKioL1fH5BCh8IW1AABFOy436uk317.png" />


效果如上。這個時候與別人效果基本相似了,現在只需要把顏色切換就可以了。(#7195B7)


然後我們回到開始的那個demo,這樣效果呢,肯定要用到position定位了,然後把它定在下邊!考慮吧如果再寫個div標籤的話

<div class="one">    日誌        <div class="triangle">    </div></div>

效果的話有興趣的各位可以試試。


還有一種是利用::after;然后里邊寫定位

one::after{    content: "";    width:0;    height:0;        border-top:10px solid #000;    border-left:10px solid #000;    border-right:10px solid #000;    border-bottom:10px solid transparent;}
<div class="one">日誌</div>


等我寫好了放回來!

關於html-三角的製作

聯繫我們

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