【发布时间】:2022-01-06 14:14:04
【问题描述】:
我正在尝试使用 only 转换使框从左向右滑动 像这样:
#box {
width: 150px;
height: 150px;
background: red;
position:absolute;
transition: all 2s ease-out;
right:auto;
}
.active{
background-color: green !important;
right:0 !important;
}
<div id="box" onclick="this.classList.add('active')"></div>
但由于某种原因,盒子没有向右滑动
This 解决方案有效,但没有解释
有人可以解释为什么背景颜色转换但位置不正确吗?
【问题讨论】:
-
在“自动”值上无法进行转换。你需要例如0 到 100% 之类的东西才能让它工作。在任何情况下都无法从 x 转换为 auto。
标签: javascript html css