html边框环绕一周动画,环绕式CSS边框动画
html边框环绕⼀周动画,环绕式CSS边框动画
我正在尝试使⽤纯CSS获得类似环绕效果的边框动画。
现在我在做它的⽅式是:before和:after伪元素⼤⼩发⽣变化。⼀个⽤于顶部和右侧边框,⼀个⽤于底部和左侧边框。
但是,由于宽度和⾼度的差异,我得到了怪异的效果,因为每⼀侧花费的时间相等,但是由于宽度远⼤于⾼度,因此看起来速度要快得多。在不事先知道div⼤⼩的情况下如何解决?
同样,也欢迎采⽤SCSS / vanilla CSS来获得相同动画的任何不同⽅法。
似乎我⽆法在SO上更改代码段的⼤⼩,但是如果您想玩转,这⾥是⼀个Codepen:
https://codepen.io/lollobaldo2000/pen/KKPazNw?editors = 1100
* {
box-sizing: border-box;
}
body {
background: black;
}
.square {
background: black;
display: block;
一年级数学下册复习计划width: 500px;
刘诗雯禁赛原因height: 200px;
position: absolute;
top: 50%;
left: 50%;会计顶岗实习周记
margin: -100px auto auto -250px;
}
.square:before, .square:after {
content: '';
width: 0%;
height: 0%;
position: absolute;
物质发生燃烧所需的必要条件border: 1px solid #FB0;
animation-fill-mode: forwards;
}
.square:before {
left: 0;
新员工欢迎词top: 0;
border-bottom: 0;
border-left: 0;
animation: btm 2s ease-in forwards;
}
.square:after {
visibility: hidden;
right: 0;
bottom: 0;
border-top: 0;
border-right: 0;
animation: btm 2s 2s ease-out forwards; }
@keyframes btm {
0% {
visibility: visible;
width: 0;
height: 0;
}
50% {
width: 100%;
height: 0;
}唐三的结局
100% {
width: 100%;
height: calc(100% - 1px);
visibility: visible;
}
}

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。