gpt4 book ai didi

html - 动画边框底部长度从 0 到 100

转载 作者:太空宇宙 更新时间:2023-11-04 01:01:28 25 4
gpt4 key购买 nike

我需要在不使用 :before 或 :after 或修改当前 html 结构的情况下使用关键帧动画为 div 的边框底部设置动画

div{
padding:3px 6px;
display:inline-block;
position:relative;
border-bottom: 2px solid black;
}
<div><h1>Lorem Ipsum</h1></div>

最佳答案

你可以像下面这样模拟它。希望对您有所帮助。

.container {
padding: 3px 6px;
display: inline-flex;
flex-direction: column;
}

.underline {
height: 2px;
max-width: 0%;
background-color: black;
animation: drawBorder 2s ease forwards;
}

@keyframes drawBorder {
from {
max-width: 0%;
}
to {
max-width: 100%;
}
}
<div class="container">
<h1>Lorem Ipsum</h1>
<div class="underline"></div>
</div>

关于html - 动画边框底部长度从 0 到 100,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53260031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com