资讯专栏INFORMATION COLUMN

css绘制各种形状图形(第二版)

CoreDump / 2117人阅读

摘要:虽然我们现在大都使用字体图标或者图片,似乎使用来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。

虽然我们现在大都使用字体图标或者svg图片,似乎使用 CSS 来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。
一、实心圆

.circle {
    width: 120px;
    height: 120px;
    background: #8BC34A;
    border-radius: 100%;
}
二、圆环(空心圆)

.ring {
    width: 100px;
    height: 100px;
    border: 10px solid #8BC34A;
    border-radius: 100%;
}
三、椭圆

.ellipsis {
    width: 200px;
    height: 120px;
    background: #8BC34A;
    border-radius: 100px/60px;
}
四、半圆

.top-semicircle {
    width: 120px;
    height: 60px;
    background: #8BC34A;
    border-radius: 60px 60px 0px 0px;
}

.right-semicircle {
    width: 60px;
    height: 120px;
    background: #8BC34A;
    border-radius: 0 60px 60px 0;
}

.bottom-semicircle {
    width: 120px;
    height: 60px;
    background: #8BC34A;
    border-radius: 0 0 60px 60px;
}

.left-semicircle {
    width: 60px;
    height: 120px;
    background: #8BC34A;
    border-radius: 60px 0 0 60px;
}
五、四分之一圆(扇形)

.toplf-sector,
.toprt-sector,
.bottomlf-sector,
.bottomrt-sector {
    width: 60px;
    height: 60px;
    background: #8BC34A;
}

.toplf-sector {
    border-radius: 60px 0 0 0;
}

.toprt-sector {
    border-radius: 0 60px 0 0;
}

.bottomlf-sector {
    border-radius: 0 0 0 60px;
}

.bottomrt-sector {
    border-radius: 0 0 60px 0;
}
六、心形

.heart-shaped {
    width: 80px;
    height: 80px;
    background: #8BC34A;
    position: relative;
    transform: rotate(45deg);
}

.heart-shaped::before {
    content: "";
    width: 40px;
    height: 80px;
    background: #8BC34A;
    border-radius: 40px 0 0 40px;
    position: absolute;
    right: 99%;
    top: 0;
}

.heart-shaped::after {
    content: "";
    width: 80px;
    height: 40px;
    background: #8BC34A;
    border-radius: 40px 40px 0 0;
    position: absolute;
    left: 0;
    bottom: 99%;
}
七、鸡蛋

.egg {
    width: 150px;
    height: 200px;
    background: #8BC34A;
    border-radius: 75px 75px 75px 75px / 130px 130px 70px 70px;
}
八、太极八卦阵图

.taiji {
    width: 140px;
    height: 70px;
    border: 2px solid #8BC34A;
    border-bottom: 70px solid #8BC34A;
    border-radius: 100%;
    position: relative;
}

.taiji::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 25px solid #8BC34A;
    border-radius: 100%;
}

.taiji::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    width: 20px;
    height: 20px;
    background: #8BC34A;
    border: 25px solid #fff;
    border-radius: 100%;
}
九、叶子(花瓣)

.leaf1 {
    width: 80px;
    height: 80px;
    background: #8BC34A;
    border-radius: 0 80px;
}

.leaf2 {
    width: 80px;
    height: 80px;
    background: #8BC34A;
    border-radius: 40px 40px 0 40px;
}
十、五叶花瓣

.five-flower {
    position: relative;
    width: 300px;
    height: 280px;
}

.five-flower .petal {
    display: block;
    width: 120px;
    height: 120px;
    background: #8BC34A;
    border-radius: 0 120px;
    position: absolute;
    transform-origin: 100% 100%;
}

.five-flower .petal1 {
    transform: rotate(72deg);
}

.five-flower .petal2 {
    transform: rotate(144deg);
}

.five-flower .petal3 {
    transform: rotate(216deg);
}

.five-flower .petal4 {
    transform: rotate(288deg);
}
十一、牵牛花

.qiannuhua {
    position: relative;
    width: 200px;
    height: 200px;
    margin-left: 140px;
}

.qiannuhua .petal {
    display: block;
    width: 120px;
    height: 120px;
    background: #8BC34A;
    border-radius: 0 120px;
    position: absolute;
    transform-origin: 0% 100%
}

.qiannuhua .petal1 {
    transform: rotate(72deg);
}

.qiannuhua .petal2 {
    transform: rotate(144deg);
}

.qiannuhua .petal3 {
    transform: rotate(216deg);
}

.qiannuhua .petal4 {
    transform: rotate(288deg);
}
十二、风车

.fengche {
    position: relative;
    width: 200px;
    height: 200px;
}

.fengche .petal {
    display: block;
    width: 120px;
    height: 120px;
    background: #8BC34A;
    border-radius: 0 120px;
    position: absolute;
    transform-origin: 30% 100%
}

.fengche .petal1 {
    transform: rotate(72deg);
}

.fengche .petal2 {
    transform: rotate(144deg);
}

.fengche .petal3 {
    transform: rotate(216deg);
}

.fengche .petal4 {
    transform: rotate(288deg);
}
十四、小尾巴

.xwb1 {
    width: 20px;
    height: 30px;
    border-left: 8px solid #8BC34A;
    border-radius: 30px 0 0 0;
}
十五、箭头

.xwb2 {
    width: 0;
    height: 0;
    border-bottom: 10px solid #8BC34A;
    border-left: 10px solid transparent;
    position: relative;
    transform: rotate(8deg);
}

.xwb2::after {
    content: "";
    width: 20px;
    height: 18px;
    border-right: 5px solid #8BC34A;
    border-radius: 0px 40px 0 0;
    position: absolute;
    left: -30px;
    bottom: -15px;
    transform: rotate(-45deg);
}
十六、月亮

.moon {
    width: 80px;
    height: 120px;
    border-left: 40px solid #8BC34A;
    border-radius: 60px;
}
十六、三角形

.triangle-bot {
    width: 0;
    height: 0;
    border: 40px solid transparent;
    border-bottom-color: #8BC34A;
}

.triangle-top {
    width: 0;
    height: 0;
    border: 40px solid transparent;
    border-top-color: #8BC34A;
}

.triangle-lf {
    width: 0;
    height: 0;
    border: 40px solid transparent;
    border-left-color: #8BC34A;
}

.triangle-rt {
    width: 0;
    height: 0;
    border: 40px solid transparent;
    border-right-color: #8BC34A;
}

.triangle-toplf,
.triangle-toprt,
.triangle-bottomlf,
.triangle-bottomrt {
    width: 0;
    height: 0;
}

.triangle-toplf {
    border-top: 120px solid #8BC34A;
    border-right: 120px solid transparent;
}

.triangle-toprt {
    border-top: 120px solid #8BC34A;
    border-left: 120px solid transparent;
}

.triangle-bottomlf {
    border-bottom: 120px solid #8BC34A;
    border-right: 120px solid transparent;
}

.triangle-bottomrt {
    border-bottom: 120px solid #8BC34A;
    border-left: 120px solid transparent;
}

.triangle1 {
    border-bottom: 120px solid #8BC34A;
    border-right: 60px solid transparent;
}

.triangle2 {
    border-top: 120px solid #8BC34A;
    border-left: 60px solid transparent;
}

.triangle3 {
    border-top: 60px solid #8BC34A;
    border-right: 120px solid transparent;
}

.triangle4 {
    border-top: 60px solid #8BC34A;
    border-left: 120px solid transparent;
}

.triangle5 {
    border-top: 80px solid #8BC34A;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
}
十七、梯形

.tixing1 {
    border-bottom: 100px solid #8BC34A;
    border-left: 60px solid transparent;
    border-right: 60px solid transparent;
    width: 100px;
    height: 0;
}

.tixing2 {
    border-bottom: 120px solid #8BC34A;
    border-right: 120px solid transparent;
    width: 80px;
}
十八、边框对话框

.duihuakuang {
    width: 200px;
    height: 100px;
    border: 2px solid #8BC34A;
    border-radius: 6px;
    position: relative;
}

.duihuakuang::before {
    content: "";
    width: 20px;
    height: 20px;
    background: #fff;
    border-right: 2px solid #8BC34A;
    border-bottom: 2px solid #8BC34A;
    position: absolute;
    left: 30%;
    top: 100%;
    transform: rotate(45deg);
    margin-top: -10px;
}
十九、锁

.suo {
    width: 200px;
    height: 160px;
    background: #8BC34A;
    border-radius: 30px;
    position: relative;
}
/*锁孔*/
.suo::before {
    content: "";
    width: 25px;
    height: 50px;
    background: #fff;
    position: absolute;
    left: 50%;
    top: 50%;
    border-radius: 25px;
    transform: translate(-50%, -50%);
}
/*锁把*/
.suo::after {
    content: "";
    width: 80px;
    height: 70px;
    border: 20px solid #8BC34A;
    background: #fff;
    border-radius: 60px 60px 0 0;
    position: absolute;
    left: 50%;
    bottom: 89%;
    transform: translateX(-50%);
}
二十、立体球型

.qiu1 {
    width: 120px;
    height: 120px;
    background: #8BC34A;
    background-image: radial-gradient(at 20% 30%, #e5ffc7, #75af33, #375f0a);
    border-radius: 100%;
}
二十一、圆柱

 
.cylinder {
    position: relative;
    transform: rotateX(70deg);
}

.ellipse {
    width: 100px;
    height: 100px;
    background: deepskyblue;
    border-radius: 50px;
}

.rectangle {
    width: 100px;
    height: 400px;
    position: absolute;
    opacity: 0.6;
    background: deepskyblue;
    top: 0;
    left: 0;
    border-radius: 50px;
    z-index: -1;
}

更多形状图形持续更新,欢迎大家讨论提出问题
(CSS渐变绘制切角效果)

参考文章:
http://www.imooc.com/article/...

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/114692.html

相关文章

  • css绘制各种形状图形二版

    摘要:虽然我们现在大都使用字体图标或者图片,似乎使用来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。 虽然我们现在大都使用字体图标或者svg图片,似乎使用 CSS 来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。 一、实心圆 showImg(https://segmentfault.com/img/bVbsV6v?w=171&h...

    LiuZh 评论0 收藏0
  • css绘制各种形状图形二版

    摘要:虽然我们现在大都使用字体图标或者图片,似乎使用来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。 虽然我们现在大都使用字体图标或者svg图片,似乎使用 CSS 来做图标意义不是很大,但怎么实现这些图标用到的一些技巧及思路是很值得我们的学习。 一、实心圆 showImg(https://segmentfault.com/img/bVbsV6v?w=171&h...

    yibinnn 评论0 收藏0
  • 翻译 | 编写SVG的口袋指南(上)

    摘要:元素元素归属于容器和结构元素,在文档内允许嵌套使用独立的片段。如果包含葡萄的组被移动到文档的末尾,它将出现在西瓜的前面。例如,将葡萄的茎的路径移动到组的末尾将导致茎在顶部。 作者:DDU(沪江前端开发工程师)本文是原文翻译,转载请注明作者及出处。 简介 Scalable Vector Graphics (SVG)是在XML中描述二维图形的语言。这些图形由路径,图片和(或)文本组成,并能...

    Brenner 评论0 收藏0
  • 翻译 | 编写SVG的口袋指南(上)

    摘要:元素元素归属于容器和结构元素,在文档内允许嵌套使用独立的片段。如果包含葡萄的组被移动到文档的末尾,它将出现在西瓜的前面。例如,将葡萄的茎的路径移动到组的末尾将导致茎在顶部。 作者:DDU(沪江前端开发工程师)本文是原文翻译,转载请注明作者及出处。 简介 Scalable Vector Graphics (SVG)是在XML中描述二维图形的语言。这些图形由路径,图片和(或)文本组成,并能...

    linkFly 评论0 收藏0
  • css绘制各种各样的形状图形

    摘要:我们在编写前端代码时,经常会遇到各种各样的形状图形如边框对话框,三角形,平行四边形圆角边框圆形四叶草花瓣等,除了用背景图片雪碧图或精灵图定位引用和插入图片的方法,我们还可以用边框圆角渐变和定位的方法结合使用,绘制各种各样的形状图形。 我们在编写前端代码时,经常会遇到各种各样的形状图形(如:边框对话框,三角形,平行四边形、圆角边框、圆形、四叶草、花瓣等),除了用背景图片(css雪碧图或c...

    mingde 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<