用css3制作各种图形

矩形

width=height

.aa{
      width: 100px;
      height: 100px;
      background: red;
}
<div class="aa"></div>

长方形

width!=height

.aa{
      width: 100px;
      height: 150px;
      background: red;
}
<div class="aa"></div>

.aa{
      width: 100px;
      height: 150px;
      background: red;
      border-radius:50%;
}
<div class="aa"></div>

圆环

.aa{
      width: 100px;
      height: 100px;
      
      border-radius: 50%;
      border:20px solid transparent;
      border-left-color:red;
      border-top-color: #f60;
      border-bottom-color: blue;
      border-right-color: green; 
    }
<div class="aa"></div>

半圆

 .aa{
      width: 100px;
      height: 50px;
      background: red;
      border-radius: 50px 50px 0 0;
    
    }
<div class="aa"></div>

1/4圆

 .aa{
      width: 100px;
      height: 100px;
      background: red;
      border-radius: 100px 0 0;
    
    }
<div class="aa"></div>

椭圆

 .aa{
      width: 100px;
      height: 200px;
      background: red;
      border-radius: 100px/200px;
    
    }
<div class="aa"></div>

椭圆环

  .aa{
      width: 100px;
      height: 200px;
      background: red;
      border-radius: 100px/200px;
      position: relative;
    
    }
    .aa .bb{
      width: 100px;
      height: 200px;
      background: #fff;
      border-radius: 100px/200px;
      position: absolute;
      transform: scale(0.5,0.5);
    }
<div class="aa">
  <div class="bb"></div>
</div>

总结:诸如环/对称可以看出利用复制+css3的rotate()/translate()/sacle()可以起到非常好的效果

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 各种纯css图标 CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出。直接用CSS3画出这些图形,要比...
    剑残阅读 13,295评论 0 8
  • 1.长方形 #Rectangle{ width: 200px; height: 50px; background-...
    一直以来都很好阅读 3,424评论 0 0
  • 转载请声明 原文链接 关注公众号获取更多资讯 这篇文章主要总结H5的一些新增的功能以及一些基础归纳,这里只是一个提...
    前端进阶之旅阅读 12,966评论 22 225
  • 刚学习了这个案例,然后觉得比较好玩,就练习了一下。然后发现其实也不难,如果你经常使用PS或者Flash的话,应该就...
    aymincoder阅读 3,505评论 0 3
  • 选择qi:是表达式 标签选择器 类选择器 属性选择器 继承属性: color,font,text-align,li...
    wzhiq896阅读 5,891评论 0 2

友情链接更多精彩内容