更新第22个小实例

This commit is contained in:
DESKTOP-BM6RJU5\wyanh 2021-10-22 18:00:47 +08:00
parent dec9d47913
commit a9ca3908de
3 changed files with 105 additions and 1 deletions

View File

@ -25,4 +25,5 @@
18. HTML+CSS小实例之简约不简单的社交分享按钮
19. HTML+CSS小实例之有趣的沙漏加载动画
20. HTML+CSS小实例之文字裂开效果
21. HTML+CSS小实例之手风琴式加载动画
21. HTML+CSS小实例之手风琴式加载动画
22. HTML5+CSS3小实例之分享按钮切换效果

80
css/22.css Normal file
View File

@ -0,0 +1,80 @@
body{
/* 取消页面内外边距 */
margin: 0;
padding: 0;
/* 100%窗口高度 */
height: 100vh;
/* 渐变背景 */
background: linear-gradient(200deg,#f3e7e9,#e3eeff);
/* 弹性布局 水平、垂直居中 */
display: flex;
justify-content: center;
align-items: center;
}
.share-button{
width: 300px;
height: 80px;
background-color: #fff;
border-radius: 40px;
display: flex;
justify-content: center;
align-items: center;
position: relative;
cursor: pointer;
/* 溢出隐藏 */
overflow: hidden;
/* 加个动画过渡 */
transition: 0.3s linear;
}
.share-button:hover{
/* 放大1.1倍 */
transform: scale(1.1);
}
.share-button span{
position: absolute;
width: 100%;
height: 100%;
background-color: #333;
color: #fff;
font-size: 18px;
text-align: center;
line-height: 80px;
border-radius: 40px;
z-index: 1;
/* 动画过渡 */
transition: 0.6s linear;
}
.share-button:hover span{
/* 沿X轴移动 */
transform: translateX(-100%);
/* 动画延迟 */
transition-delay: 0.3s;
}
.share-button a{
flex: 1;
font-size: 26px;
color: #333;
text-align: center;
transform: translateX(-100%);
/* 不透明度 */
opacity: 0;
transition: 0.3s linear;
}
.share-button:hover a{
opacity: 1;
transform: translateX(0);
}
/* 接下来为每一个a元素图标分别设置动画延迟 */
/* :nth-of-type(n)选择器是匹配属于父元素的特定类型的第n个子元素的每个元素 */
.share-button a:nth-of-type(1){
transition-delay: 1s;
}
.share-button a:nth-of-type(2){
transition-delay: 0.8s;
}
.share-button a:nth-of-type(3){
transition-delay: 0.6s;
}
.share-button a:nth-of-type(4){
transition-delay: 0.4s;
}

23
html/22.html Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>分享按钮切换效果</title>
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" href="../css/22.css">
</head>
<body>
<div class="share-button">
<span><i class="fa fa-share-alt" aria-hidden="true"></i> 去分享</span>
<a href="#"><i class="fa fa-qq" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-weixin" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-weibo" aria-hidden="true"></i></a>
<a href="#"><i class="fa fa-renren" aria-hidden="true"></i></a>
</div>
</body>
</html>