一、利用阴影画一个月亮

说明:画月亮,需要先画一个圆,然后利用box-shadow属性,生成阴影,再将圆的颜色变为透明即可。

<html>
<head></head>
<body>
<style>
.moon {
margin: auto;
margin-top: 100px;
width: 100px;
height: 100px;
/* transparent 当前背景色 */
background-color: yellow;
/* 圆角边框,设定大于等于50%时,正方形会变成圆 */
border-radius: 70%;
/* box-shadow参数:水平位移/垂直位移/模糊距离(可选)/颜色 */
box-shadow: 50px 0px 0px orange;
} </style> <div class="moon"></div>
</body>
<foot></foot>
</html>

二、画一颗爱心

说明:利用before,after伪类在菱形(正方形旋转45度)两侧伸出,并设定圆形边框。

<html>
<head></head>
<body>
<style>
.heart {
margin: auto;
margin-top: 100px;
width: 100px;
height: 100px;
transform: rotate(-45deg);
background-color: pink;
} /* 伪类before,after,在元素前后插入 */
.heart:before {
/* 定位要取absolute,即相对heart类的盒子位置调整 */
position: absolute;
/* content 为必填字段 */
content: "";
width: 100px;
height: 100px;
/* 向上延伸 */
top: -50px;
left: 0px;
border-radius: 50%;
background-color: pink;
} .heart:after {
position: absolute;
content: "";
width: 100px;
height: 100px;
top: 0px;
/* 向右延伸 */
left: 50px;
border-radius: 50%;
background-color: pink;
}
</style> <div class="heart"></div>
</body>
<foot></foot>
</html>

三、使爱心跳动起来

说明:应用了动画属性animation-name, animation-duration, animation-iteration-count,  @keyframes等,让爱心间接性变大缩小。

<html>
<head></head>
<body>
<style>
.heart {
margin: auto;
margin-top: 100px;
width: 100px;
height: 100px;
transform: rotate(-45deg);
background-color: pink;
/* 对应的动作名 */
animation-name: beat;
/* 动作持续的时间 */
animation-duration: 1s;
/* 动作循环的次数,infinite表示无限次 */
animation-iteration-count: infinite;
} /* 帧动作 在持续时间里对应百分比 css属性的变化 */
@keyframes beat {
0% {
/* scale 放大倍数 */
transform: scale(0.8) rotate(-45deg);
} 50% {
transform: scale(1.1) rotate(-45deg);
} } /* 伪类before,after,在元素前后插入 */
.heart:before {
/* 定位要取absolute,即相对heart类的盒子位置调整 */
position: absolute;
/* content 为必填字段 */
content: "";
width: 100px;
height: 100px;
/* 向上延伸 */
top: -50px;
left: 0px;
border-radius: 50%;
background-color: pink;
} .heart:after {
position: absolute;
content: "";
width: 100px;
height: 100px;
top: 0px;
/* 向右延伸 */
left: 50px;
border-radius: 50%;
background-color: pink;
}
</style> <div class="heart"></div>
</body>
<foot></foot>
</html>

四、彩色弹跳球

<html>
<head></head> <body>
<style>
.colorful-ball {
position: absolute;
width: 100px;
height: 100px;
border-radius: 50%;
background: linear-gradient(90deg, blue, white, yellow, orange);
top: 50px;
left: 300px;
animation-name: fall-down;
animation-duration: 1s;
animation-iteration-count: infinite;
/* 表示动作播放速度 ease-in:先慢后快; ease-out:先快后慢; ease-in-out:先慢后快再慢; cubic-bezier(n,n,n,n):自定义速度曲线 */
animation-timing-function: ease-in;
} @keyframes fall-down {
50% {
top: 200px;
} 100% {
top: 50px;
}
}
</style> <div class="colorful-ball"></div>
</body> <foot></foot>

最新文章

  1. objective-c第七章课后练习3
  2. javascript学习内容--object.style.display=&quot;value&quot; value值为“”none“隐藏”或 &quot;block&quot;显示
  3. Datagridview 列绑定
  4. Android 获取SDCard中某个目录下图片
  5. Android开发ScrollView上下左右滑动事件冲突整理一(根据事件)
  6. 关于tableView刷新
  7. MONO 如何打包 .NET程序独立运行(winform篇)
  8. .Net程序员学用Oracle系列(22):分析函数(OVER)
  9. 自学Zabbix3.5.5-监控项item-User parameters(自定义key)
  10. POJ3261:Milk Patterns
  11. head里两个重要标签base和meta
  12. JS -- serializeJSON
  13. 浅谈提高Django性能
  14. Luogu4512 【模板】多项式除法(多项式求逆+NTT)
  15. golang flag简单用法
  16. Valid Mountain Array LT941
  17. IIS并发连接数及性能优化
  18. 【JMeter】如何录制创建及得到曲线图
  19. 适配 iOS 11 &amp; iPhone X 大全
  20. ES6——Class 的基本使用

热门文章

  1. 瑞士军刀 sox 系列 :给.raw文件添加header变身.wav文件
  2. Arrays.sort()降序排序
  3. MFC程序运行原理初探
  4. Promise的几个方法解析
  5. 为什么常用Formdata对象来上传图片
  6. RTT笔记-分析自动初始化机制转
  7. TinyRadius客户端java登录认证
  8. spark项目技术点整理
  9. react module.scss文件中弹窗中 keyframes动画不生效,
  10. 最长上升子序列(LIS) dp典型例题(tzoj 矩形嵌套,Rectangles )