纯css制作带三角(兼容所有浏览器)
生活随笔
收集整理的這篇文章主要介紹了
纯css制作带三角(兼容所有浏览器)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
如何用 border 來制作三角。
html 代碼如下:
<div class="arrow-up"></div> <div class="arrow-down"></div> <div class="arrow-left"></div> <div class="arrow-right"></div>
css 代碼如下:
效果圖如下:
?
?
?
?
?
首先附上效果圖:
以上的效果完全是用 css 來實現的,那么是怎么實現的呢?
我們知道 html 中有一些特殊的字符,具體的請點擊?HTML特殊字符大全。
通過特殊字符,利用 css 中的 margin 或者 position 方法完全可以實現以上效果。
代碼如下: <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8"> <title>字符制作三角邊框</title> <style type="text/css"> *{margin:0;padding:0;} body{font-family:SimSun;} h1{text-align:center;} .demo1{width:300px;margin:20px auto;border:1px solid red;height:100px;} .demo1 em,.demo1 span{display:block;width:30px;height:16px;font-size:30px;overflow:hidden;_position:relative;margin-left:10px;} .demo1 em{margin-top:-16px;color:red;font-style:normal;} .demo1 span{margin-top:-14px;color:white;}.demo2{width:300px;border:1px solid #F00;height:100px;position:relative;margin-left:auto;margin-right:auto;} .demo2 em,.demo2 span{font-style:normal;font-size:30px;position:absolute;left:-16px;top:40px;color:red;} .demo2 span{left:-14px;color:white;} </style> </head> <body> <h1>demo1 是用 margin 方法</h1> <div class="demo1"> <em>◆</em> <span>◆</span> </div> <h1>demo2 是用 position 方法</h1> <div class="demo2"> <em>◆</em> <span>◆</span> </div> </body> </html>?
總結
以上是生活随笔為你收集整理的纯css制作带三角(兼容所有浏览器)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GridView里面嵌套RadioBut
- 下一篇: 『原创』+『参考』使用C#在PPC的To