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

45个值得收藏的CSS形状

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

22.无穷大

  1. #infinity {  
  2. position: relative;  
  3. width: 212px;  
  4. height: 100px;  
  5. box-sizing: content-box;  
  6. }  
  7. #infinity:before,  
  8. #infinity:after {  
  9. content: "";  
  10. box-sizing: content-box;  
  11. position: absolute;  
  12. top: 0;  
  13. left: 0;  
  14. width: 60px;  
  15. height: 60px;  
  16. border: 20px solid red;  
  17. border-radius: 50px 50px 0 50px;  
  18. transform: rotate(-45deg);  
  19. }  
  20. #infinity:after {  
  21. left: auto;  
  22. right: 0;  
  23. border-radius: 50px 50px 50px 0;  
  24. transform: rotate(45deg);  
  25. }  

23.菱形

  1. #diamond {  
  2. width: 0;  
  3. height: 0;  
  4. border: 50px solid transparent;  
  5. border-bottom-color: red;  
  6. position: relative;  
  7. top: -50px;  
  8. }  
  9. #diamond:after {  
  10. content: '';  
  11. position: absolute;  
  12. left: -50px;  
  13. top: 50px;  
  14. width: 0;  
  15. height: 0;  
  16. border: 50px solid transparent;  
  17. border-top-color: red;  
  18. }  

24.钻石

  1. #diamond-shield {  
  2. width: 0;  
  3. height: 0;  
  4. border: 50px solid transparent;  
  5. border-bottom: 20px solid red;  
  6. position: relative;  
  7. top: -50px;  
  8. }  
  9. #diamond-shield:after {  
  10. content: '';  
  11. position: absolute;  
  12. left: -50px;  
  13. top: 20px;  
  14. width: 0;  
  15. height: 0;  
  16. border: 50px solid transparent;  
  17. border-top: 70px solid red;  
  18. }  

25.钻戒

  1. #diamond-narrow {  
  2. width: 0;  
  3. height: 0;  
  4. border: 50px solid transparent;  
  5. border-bottom: 70px solid red;  
  6. position: relative;  
  7. top: -50px;  
  8. }  
  9. #diamond-narrow:after {  
  10. content: '';  
  11. position: absolute;  
  12. left: -50px;  
  13. top: 70px;  
  14. width: 0;  
  15. height: 0;  
  16. border: 50px solid transparent;  
  17. border-top: 70px solid red;  
  18. }  

(编辑:晋中站长网)

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

热点阅读