gpt4 book ai didi

html - 如何使用 css3 动画将宽度和高度设置为 100%?

转载 作者:行者123 更新时间:2023-12-01 22:37:22 28 4
gpt4 key购买 nike

我有以下代码

HTML

<div></div>

CSS

div {
background: tomato;
width: 100px;
height: 100px;
-webkit-animation: animateThis 0.3s ease-in;
-webkit-animation-fill-mode: forwards;
}

@-webkit-keyframes animateThis {
0% {
width: 100px;
height: 100px;
}
100% {
width: 100%;
height: 100%;

}
}

DEMO

我想做的是我想将 div 的高度和高度放大到 100% 以覆盖整个浏览器。我不知道如何制作 100% 高度的动画。我在谷歌上搜索了一下。没有找到运气

最佳答案

您需要指定 100% 的内容..在本例中,为 html/body

* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
}
div {
background: tomato;
width: 100px;
height: 100px;
-webkit-animation: animateThis 1s ease-in;
-webkit-animation-fill-mode: forwards;
}
@-webkit-keyframes animateThis {
0% {
width: 100px;
height: 100px;
}
100% {
width: 100%;
height: 100%;
}
}
<div></div>

关于html - 如何使用 css3 动画将宽度和高度设置为 100%?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29880369/

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