利用css的伪元素before、after实现蒸锅

阅读《CSS3艺术》练习codepen.io
在这里插入图片描述

<figure class="steamer">
  <div class='lid'></div>
  <div class='pot'></div>
</figure>
/*设置全局样式*/
html,body {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: pink;
  height: 100%;
  margin: 0;
}
/*设置白色背景,圆形容器, 作为蒸锅背景*/
.steamer {
  width: 30em;
  height: 30em;
  border-radius: 50%;
  background-color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
}
/* 紫色锅身 */
.pot {
  width: 16em;
  height: 12em;
  background-color: darkslateblue;
  border-radius: 0.5em 0.5em 6.5em 6.5em;
  border-right: 1.5em solid midnightblue;
  position: relative;
}
/* 绘制锅身把手,一个长条,置于锅身下层*/
.pot:before {
  content: "";
  position: absolute;
  width: 27em;
  height: 2.5em;
  background-color: tomato;
  border-radius: 1.25em;
  left: -4.75em;
  top: 1em;
  z-index: -1;
}
/*绘制锅盖*/
.lid {
  width:17em;
  height:6em;
  background-color: gold;
  border-radius: 6em 6em 0 0;
  border-right: 1.5em solid goldenrod;
  border-bottom: 1.2em solid goldenrod;
  position: relative;
/*   top: 0.5em; */
  z-index:1;
}
/*绘制锅盖提钮*/
.lid:before {
  content:'';
  position:absolute;
  width:4em;
  height:4em;
  background-color:tomato;
  border-radius:50%;
  left:7em;
  top:-2em;
}

/* 增加光影效果,锅盖和锅身上的白色线条 */

.pot:after {
  content:'';
  width:8em;
  height:8em;
  border:0.6em solid;
  border-color: transparent transparent white transparent;
  position:absolute;
  border-radius: 50%;
  transform: rotate(30deg);
  top:1em;
  left:2em;
}


.lid:after {
  content:'';
  width:7em;
  height:7em;
  border:0.6em solid;
  border-color: transparent transparent  transparent white;
  position:absolute;
  border-radius: 50%;
  transform: rotate(40deg);
  top:1em;
  left:1.5em;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

青菜小王子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值