原文地址:https://segmentfault.com/a/1190000015376202

感想: 好像不像呀,啊啊啊。伪元素、定位、动画、width和height包括内边距|边框|内容区。

HTML code:

<!-- 定义 dom,容器中包含 1 个元素表示壶体,其中再包含 1 个元素表示壶把手 -->
<div class="container">
<div class="pot">
<div class="handle"></div>
</div>
</div>

CSS code:

html, body {
margin:;
padding:;
}
*,
*::before,
*::after{
/* 设置元素的width、height包括内边距、边框、内容区 */
box-sizing: border-box;
}
/* 设置body的子元素水平垂直居中 */
body{
height: 100vh;
display: flex;
/* 排不下就换行 */
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
background: linear-gradient(to right bottom, silver, dimgray);
}
/* 设置容器样式 */
.container {
width: 150px;
height: 150px;
border-radius: 50%;
background-color: snow;
display: flex;
justify-content: center;
align-items: center;
animation: pouring 3s linear infinite alternate;
}
/* 再用伪元素给壶加上光影 */
.container::after {
content: '';
position: absolute;
width: 70px;
height: 70px;
border: 3px solid transparent;
border-left-color: white;
border-radius: 50%;
left: 40px;
top: 40px;
transform: rotate(-10deg);
}
@keyframes pouring {
0%, 25% {
transform: rotate(0deg);
} 75%, 100% {
transform: rotate(-45deg);
}
}
.pot {
position: relative;
width: 85px;
height: 85px;
/* 阴影 */
border-right: 5px solid steelblue;
border-radius: 50%;
background-color: deepskyblue;
}
/* 用伪元素画出壶的上半部分 */
.pot::before {
content: '';
position: absolute;
width: 85px;
height: 43px;
border-right: 5px solid palevioletred;
border-radius: 43px 43px 0 0;
background-color: hotpink;
}
/* 用伪元素画出壶嘴 */
.pot::after {
content: '';
width: 43px;
height: 10px;
position: absolute;
left: 21px;
top: -3px;
background-color: hotpink;
}
/* 画出把手横向的部分 */
.pot .handle {
width: 83px;
height: 7px;
border-radius: 7px;
background-color: black;
position: absolute;
left: 13px;
top: 12px;
}
/* 用伪元素画出把手竖向的部分: */
.pot .handle::before {
content: '';
width: 7px;
height: 50px;
border-radius: 7px;
background-color: black;
position: absolute;
left: calc(85px - 7px);
}

61.纯 CSS 创作一只咖啡壶(这个不好看)的更多相关文章

  1. 前端每日实战:61# 视频演示如何用纯 CSS 创作一只咖啡壶

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/ZRjGGy 可交互视频 此视频是可 ...

  2. 73.纯 CSS 创作一只卡通狐狸

    原文地址:https://segmentfault.com/a/1190000015566332 学习效果地址:https://scrimba.com/c/cz6EzdSd 感想:过渡效果,圆角,定位 ...

  3. 70.纯 CSS 创作一只徘徊的果冻怪兽

    原文地址:https://segmentfault.com/a/1190000015484852 感想:monster中边框角.上下动画.旋转动画.左右动画,眼睛中transform:scaleY(n ...

  4. 62.纯 CSS 创作一只蒸锅(感觉不好看呀)

    原文地址:https://segmentfault.com/a/1190000015389338 HTML code: <!-- steamer: 蒸锅: lid: 盖子: pot: 锅 --& ...

  5. 58.纯 CSS 创作一只卡通鹦鹉

    原文地址:https://segmentfault.com/a/1190000015339977 优化后效果地址:https://scrimba.com/c/c97Z2vuD 感想:消除了图片外的:h ...

  6. 前端每日实战:103# 视频演示如何用纯 CSS 创作一只监视眼

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/GBzLdy 可交互视频 此视频是可 ...

  7. 前端每日实战:111# 视频演示如何用纯 CSS 创作一只艺术的鸭子

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/aaoveW 可交互视频 此视频是可 ...

  8. 如何用纯 CSS 创作一只徘徊的果冻怪兽

    效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/VdOKQG 可交互视频 ...

  9. 前端每日实战:98# 视频演示如何用纯 CSS 创作一只愤怒小鸟中的绿猪

    效果预览 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/VBGWqX 可交互视频 此视频是可 ...

随机推荐

  1. Android stdio 报错 error invoking main method

    打开Android stdio失败 报错:error invoking main method 想想前一天做了什么事?? 昨天把企图把Android Stdio文件包移盘,但是中途截止了,也就是说移动 ...

  2. websocket随笔

    https://github.com/littlechaser/push-service 我们在浏览器调服务器的时候使用http连接通常就能实现,但是如果要服务器数据发生变化,需要主动推送给客户端(如 ...

  3. 《TypeScript 中文入门教程》

    转载:<TypeScript 中文入门教程> 17.注解 (2015-12-03 11:36) 转载:<TypeScript 中文入门教程> 16.Symbols (2015- ...

  4. Python基础03_pycharm

    pycharm的安装还是很简单的,一路next. 看起来Jet Brains 家的产品长相都差不多啊. 主要是create new project时,路径和解释器的选择,我电脑上有2.7和3.6 所以 ...

  5. java面向对象编程(六)--四大特征之继承

    本文将介绍继承.方法重载和方法覆盖.其中方法重载和方法覆盖是在讲多态时必须要清楚的一个知识点. 一.继承 1.继承的概念 继承可以解决代码复用,让我们的编程更加靠近人类思维.当多个类存在相同的属性(变 ...

  6. jquery mCustomScrollbar 滚动条宽度的设置

    一.项目使用 $("#iscroll-1, #tree_box, .work, .item1, .item2, .item3, .item4").mCustomScrollbar( ...

  7. Day 1: ASP.NET and JavaScript Jan.16th Trying

    ASP.NET has its own named controls(tags) corresponding to that in an HTML document, such as <asp: ...

  8. [Split The Tree][dfs序+树状数组求区间数的种数]

    Split The Tree 时间限制: 1 Sec  内存限制: 128 MB提交: 46  解决: 11[提交] [状态] [讨论版] [命题人:admin] 题目描述 You are given ...

  9. 【转】python两个 list 获取交集,并集,差集的方法

    1. 获取两个list 的交集: #方法一: a=[2,3,4,5] b=[2,5,8] tmp = [val for val in a if val in b] print tmp #[2, 5] ...

  10. Go之unsafe.Pointer && uintptr 类型

    Go语言是个强类型语言.Go语言要求所有统一表达式的不同的类型之间必须做显示的类型转换.而作为Go语言鼻祖的C语言是可以直接做隐式的类型转换的. 也就是说Go对类型要求严格,不同类型不能进行赋值操作. ...