【发布时间】:2021-12-06 13:26:36
【问题描述】:
关闭蝙蝠:scale() 不是一个有效的选项。
如何根据以下信息将宽度或高度为 700% 的图像动态动画化回原始 css 宽度自动和/或高度自动。
我的图片 ( .backone > img ) 具有以下实际 ||实际尺寸:
1024 像素宽度 570px 高度
我的图片CSS如下:
/*this is the same as the window width and height*/
.backone {
width: 100%;
height: 100%;
z-index: 6;
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
/** the original CSS dimensions **/
.backone > img {
position: absolute;
width: auto;
height: auto;
min-height: 100%;
min-width: 100%;
left: 50%;
top: 0px;
bottom: auto;
transform: translateX(-50%);
}
在脚本执行过程中,我向 .backone > img 添加了 700% 的高度或 700% 的宽度(当它被隐藏时),具体取决于窗口的宽度是否大于高度.
现在,当图像显示时,我想将其动画化回上面的“原始 css”尺寸。
我尝试过的:
-
在添加 700% 宽度之前捕获图像的宽度和高度 ||高度,这不起作用,因为图像被隐藏并且尚未到达 DOM。
-
css 动画,但这限制了我将宽度或高度返回到 100%,并扭曲了图像。
-
多次尝试使用 jQuery animate 来获得正确的尺寸,但我可以得到正确的计算。
我可以使用哪些计算来将图像恢复到其原始尺寸。
【问题讨论】:
标签: jquery css jquery-animate zooming