我有一个父div,其中有一个子div。当我悬停在父div上时,我想使用“float”属性将子div从左转换到右。它确实正常地向右浮动,但没有任何过渡持续时间或过渡函数,就好像不存在过渡一样。
我尝试用“width”,“height”和“backgrounder-color”属性进行过渡,它们都很好,但是“float”不行。
为什么过渡对“浮点”属性不起作用?
HTML代码:
<div class="parent">
<div class="child"></div>
</div>
CSS代码:
.parent{
height: 400px;
width: 400px;
outline: black solid thick;
}
.child{
height: 10%;
width: 10%;
border-radius: 50%;
background-color: blue;
transition: float 2s;
}
.parent:hover .child{
float: right;
}
您不能对float属性使用转换,但是,您仍然可以通过不同的方法来实现您所需要的,请查看上一篇文章中添加的解决方案