加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 建站 > 正文

45个值得收藏的CSS形状

发布时间:2019-04-24 08:32:00 所属栏目:建站 来源:前端小智
导读:CSS能够生成各种形状。正方形和矩形很容易,因为它们是 web 的自然形状。添加宽度和高度,就得到了所需的精确大小的矩形。添加边框半径,你就可以把这个形状变成圆形,足够多的边框半径,你就可以把这些矩形变成圆形和椭圆形。 我们还可以使用 CSS 伪元素

19.六边形

  1. #hexagon {  
  2. width: 100px;  
  3. height: 55px;  
  4. background: red;  
  5. position: relative;  
  6. }  
  7. #hexagon:before {  
  8. content: "";  
  9. position: absolute;  
  10. top: -25px;  
  11. left: 0;  
  12. width: 0;  
  13. height: 0;  
  14. border-left: 50px solid transparent;  
  15. border-right: 50px solid transparent;  
  16. border-bottom: 25px solid red;  
  17. }  
  18. #hexagon:after {  
  19. content: "";  
  20. position: absolute;  
  21. bottom: -25px;  
  22. left: 0;  
  23. width: 0;  
  24. height: 0;  
  25. border-left: 50px solid transparent;  
  26. border-right: 50px solid transparent;  
  27. border-top: 25px solid red;  
  28. }  

20.八边形

  1. #octagon {  
  2. width: 100px;  
  3. height: 100px;  
  4. background: red;  
  5. position: relative;  
  6. }  
  7. #octagon:before {  
  8. content: "";  
  9. width: 100px;  
  10. height: 0;  
  11. position: absolute;  
  12. top: 0;  
  13. left: 0;  
  14. border-bottom: 29px solid red;  
  15. border-left: 29px solid #eee;  
  16. border-right: 29px solid #eee;  
  17. }  
  18. #octagon:after {  
  19. content: "";  
  20. width: 100px;  
  21. height: 0;  
  22. position: absolute;  
  23. bottom: 0;  
  24. left: 0;  
  25. border-top: 29px solid red;  
  26. border-left: 29px solid #eee;  
  27. border-right: 29px solid #eee;  
  28. }  

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读