gpt4 book ai didi

css - Webkit 动画仅将矩形 div 的右边缘向左移动

转载 作者:太空宇宙 更新时间:2023-11-04 08:51:40 24 4
gpt4 key购买 nike

考虑一个宽度为 100%、高度为 100vh 的 div。我想将它缩小到 50% 宽度,为此只有它的右手边缘必须从 100% 到 50%。

我怎样才能做到这一点?

更新:

我的 HTML(它是 react ):

<div className={classNames("div-one", { "half-width": this.state.showRegistration })}>
</div>

和CSS:

.div-one {

background: url("../../../assets/images/manhattan-min.png") no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;

position: absolute;
width: 100%;
min-height: 500px;
min-height: 100vh;

}

.div-one.half-width {
width: 50%;
-webkit-animation: right-to-left-div1 0.2s forwards;
animation: right-to-left-div1 0.2s forwards;

}

@keyframes right-to-left-div1{
from{left:10%}
to{left:0%}
}

最佳答案

如果我理解这个问题,你可以将宽度设置为 50%

div {
position: absolute;
min-height: 500px;
min-height: 100vh;
width: 100%;
background: green;
-webkit-animation: right-to-left-div1 0.2s forwards;
animation: right-to-left-div1 0.2s forwards;
}

@keyframes right-to-left-div1{
to {
width: 50%;
}
}
<div></div> 

关于css - Webkit 动画仅将矩形 div 的右边缘向左移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43396356/

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