小编qun*_*nzi的帖子

如何仅使用 CSS 创建三角形动画

我想构建这样的动画,但只使用 css:

在此处输入图片说明

我建立了一个三角形,但我无法建立一个会移动的移动三角形的背景。请参阅图片中的示例。

我的代码:

HTML:

 <div class="container">
        <div class="triangle up">
        </div>
        <div class="triangle down-right">

        </div>
        <div class=" down-right1">
        </div>

        <div class="triangle down-left">
        </div>
    </div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.container {
    position: relative;
    left: 45%;
    width: 300px;
    height: 250px;
}

.triangle {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 50px solid transparent;
    border-right: 50px solid transparent;
    border-bottom: 100px solid rgb(165,60,255);
    background: linear-gradient(90deg, rgba(165,60,255,1) 0%, rgba(98,0,255,1) 100%);
    z-index: 999999;
}

.up {
    top: 0;
    left: auto;
}


.down-right {
    top: 100px;
    left: 16.5%;
}

.down-right1 …
Run Code Online (Sandbox Code Playgroud)

html css css-animations

3
推荐指数
1
解决办法
318
查看次数

标签 统计

css ×1

css-animations ×1

html ×1