CSS实现DIV三角形

本文内容收集来自网络

[css]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. #triangle-up {  
  2.     width0;  
  3.     height0;  
  4.     border-left50px solid transparent;  
  5.     border-right50px solid transparent;  
  6.     border-bottom100px solid red;  
  7. }  

  
  
  1. #triangle-down {  
  2.     width0;  
  3.     height0;  
  4.     border-left50px solid transparent;  
  5.     border-right50px solid transparent;  
  6.     border-top100px solid red;  
  7. }  

[css]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. #triangle-left {  
  2.     width0;  
  3.     height0;  
  4.     border-top50px solid transparent;  
  5.     border-right100px solid red;  
  6.     border-bottom50px solid transparent;  
  7. }  

  
  
  1. #triangle-right {  
  2.     width0;  
  3.     height0;  
  4.     border-top50px solid transparent;  
  5.     border-left100px solid red;  
  6.     border-bottom50px solid transparent;  
  7. }  

  
  
  1. #triangle-topleft {  
  2.     width0;  
  3.     height0;  
  4.     border-top100px solid red;  
  5.     border-right100px solid transparent;  
  6. }  

  
  
  1. #triangle-topright {  
  2.     width0;  
  3.     height0;  
  4.     border-top100px solid red;  
  5.     border-left100px solid transparent;   
  6. }  

[css]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. #triangle-bottomleft {  
  2.     width0;  
  3.     height0;  
  4.     border-bottom100px solid red;  
  5.     border-right100px solid transparent;  
  6. }  

  
  
  1. #triangle-bottomright {  
  2.     width0;  
  3.     height0;  
  4.     border-bottom100px solid red;  
  5.     border-left100px solid transparent;  
  6. }  

[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <!-- 外框 -->  
  2. <div class="mod-container">  
  3.     <!-- 小三角部分 -->  
  4.     <div class="mod-triangle">  
  5.         <div class="t-border"></div>  
  6.         <div class="t-inset"></div>  
  7.     </div>  
  8. </div>  
[html]  view plain  copy
  在CODE上查看代码片 派生到我的代码片
  1. <pre code_snippet_id="2012450" snippet_file_name="blog_20161128_10_8798016" name="code" class="html">/*外框容器*/  
  2. .mod-container {  
  3.     width:100px;  
  4.     height:60px;  
  5.     border:1px solid #000;  
  6.     margin:20px;  
  7.     background:#fff;  
  8. }  
  9. /*小三角部分*/  
  10. .mod-triangle {  
  11.     display:block;  
  12.     position:relative;  
  13.     left:-23px;  
  14.     top:18px;  
  15.     z-index:20;  
  16. }  
  17. .mod-triangle .t-border,  
  18. .mod-triangle .t-inset{  
  19.     left:0px;  
  20.     top:0px;  
  21.     width:0;  
  22.     height:0;  
  23.     font-size:0;  
  24.     overflow:hidden;  
  25.     position:absolute;  
  26.     border-width:12px;  
  27.     /*可在此处更改小三角方向:上-右-下-左(solid的位置)*/  
  28.     border-style:dashed solid dashed dashed;  
  29. }  
  30. /*小三角的边框,如果不需要,可将颜色值改变*/  
  31. .mod-triangle .t-border{  
  32.     border-color:transparent #000 transparent transparent;  
  33.     left:-1px;  
  34. }  
  35. .mod-triangle .t-inset{  
  36.     border-color: transparent #fff transparent transparent;  
  37. }</pre><p></p>  
  38. <pre></pre>  
  39. <p></p>  
  40. <p> </p>  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值