用CSS怎样做三角形叠加放大的效果?
Admin 2021-09-26 群英技术资讯 921 次浏览
相信有一点CSS基础的朋友应该都可以轻松实现一个css三角形,那么如果我们想要更酷炫的三角形效果要怎样做呢?其实我们可以用CSS3来做一个三角形叠加放大的特效,实现效果及代码如下,感兴趣的朋友可以参考。
11.1 图片预览

11.2 index.html代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>CSS3三角形不断放大特效</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <div class="wrapper"> <svg class="triangle-canvas" viewBox="0 0 1000 1000" xmlns="http://www.w3.org/2000/svg"> <polygon class="triangle triangle-1" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-2" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-3" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-4" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-5" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-6" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-7" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-8" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-9" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-10" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-11" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-12" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-13" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-14" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-15" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-16" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-17" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-18" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-19" points="500,200 759,650 241,650" /> <polygon class="triangle triangle-20" points="500,200 759,650 241,650" /> </svg> </div> </body> </html>
11.3 style.css代码
html {
height: 100%;
}
body {
padding: 0;
margin: 0;
height: 100%;
background: #642B73;
/* fallback for old browsers */
/* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to left, #C6426E, #642B73);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.wrapper {
overflow: hidden;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.triangle-canvas {
position: absolute;
left: 50%;
top: 50%;
width: 100%;
height: 100%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.triangle {
fill: none;
stroke: #fff;
stroke-width: 15;
-webkit-transform-origin: center center;
transform-origin: center center;
-webkit-animation: triangle-animation 10s linear infinite;
animation: triangle-animation 10s linear infinite;
}
.triangle-1 {
-webkit-animation-delay: 0s;
animation-delay: 0s;
}
.triangle-2 {
-webkit-animation-delay: -0.5s;
animation-delay: -0.5s;
}
.triangle-3 {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
.triangle-4 {
-webkit-animation-delay: -1.5s;
animation-delay: -1.5s;
}
.triangle-5 {
-webkit-animation-delay: -2s;
animation-delay: -2s;
}
.triangle-6 {
-webkit-animation-delay: -2.5s;
animation-delay: -2.5s;
}
.triangle-7 {
-webkit-animation-delay: -3s;
animation-delay: -3s;
}
.triangle-8 {
-webkit-animation-delay: -3.5s;
animation-delay: -3.5s;
}
.triangle-9 {
-webkit-animation-delay: -4s;
animation-delay: -4s;
}
.triangle-10 {
-webkit-animation-delay: -4.5s;
animation-delay: -4.5s;
}
.triangle-11 {
-webkit-animation-delay: -5s;
animation-delay: -5s;
}
.triangle-12 {
-webkit-animation-delay: -5.5s;
animation-delay: -5.5s;
}
.triangle-13 {
-webkit-animation-delay: -6s;
animation-delay: -6s;
}
.triangle-14 {
-webkit-animation-delay: -6.5s;
animation-delay: -6.5s;
}
.triangle-15 {
-webkit-animation-delay: -7s;
animation-delay: -7s;
}
.triangle-16 {
-webkit-animation-delay: -7.5s;
animation-delay: -7.5s;
}
.triangle-17 {
-webkit-animation-delay: -8s;
animation-delay: -8s;
}
.triangle-18 {
-webkit-animation-delay: -8.5s;
animation-delay: -8.5s;
}
.triangle-19 {
-webkit-animation-delay: -9s;
animation-delay: -9s;
}
.triangle-20 {
-webkit-animation-delay: -9.5s;
animation-delay: -9.5s;
}
@-webkit-keyframes triangle-animation {
0% {
-webkit-transform: scale(0) rotate(0deg);
transform: scale(0) rotate(0deg);
opacity: 1;
}
100% {
-webkit-transform: scale(3) rotate(45deg);
transform: scale(3) rotate(45deg);
opacity: 0;
}
}
@keyframes triangle-animation {
0% {
-webkit-transform: scale(0) rotate(0deg);
transform: scale(0) rotate(0deg);
opacity: 1;
}
100% {
-webkit-transform: scale(3) rotate(45deg);
transform: scale(3) rotate(45deg);
opacity: 0;
}
}
以上就是用CSS3实现三角形叠加放大的特效的介绍了,上述示例具有一定的借鉴价值,希望对大家学习CSS3有帮助,想要了解更多大家可以继续浏览群英网络其他相关的文章。
文本转载自脚本之家
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
html实现可输入下拉菜单,不可思议是不是, 本例通过一些方法实现这个不可能的事情,感兴趣的朋友可以参考下html实现可输入下拉菜单的方法。
这篇文章给大家分享的是CSS让字体垂直居中的方法。小编觉得挺实用的,因此分享给大家做个参考,文中的示例代码介绍得很详细,有需要的朋友可以参考,接下来就跟随小编一起了解看看吧。
这篇文章主要介绍了CSS 埋点统计的示例代码,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
这篇文章主要介绍了VSCode 自定义html5模板的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
最近做项目遇到这样的需求,页面加载数据比较慢,一直没有反应,下面小编给大家带来了基于CSS制作提示框 ‘正在加载请。。。。。’功能,需要的朋友参考下吧
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008