我在使用css3过渡时遇到了一个问题,我如何才能使过渡变得平滑它会立即出现
我希望当我将鼠标悬停在div框上时,它会慢慢改变它的高度。
html代码
<div id="imgs">
<img src="http://chat.ecobytes.net/img/emoticons/smile.png" alt=":)" title=":)" />
<img src="http://chat.ecobytes.net/img/emoticons/sad.png" alt=":(" title=":(" />
<img src="http://chat.ecobytes.net/img/emoticons/wink.png" alt=";)" title=";)" />
<img src="http://chat.ecobytes.net/img/emoticons/razz.png" alt=":P" title=":P" />
<img src="http://chat.ecobytes.net/img/emoticons/grin.png" alt=":D" title=":D" />
<img src="http://chat.ecobytes.net/img/emoticons/plain.png" alt=":|" title=":|" />
<img src="http://chat.ecobytes.net/img/emoticons/surprise.png" alt=":O" title=":O" />
<img src="http://chat.ecobytes.net/img/emoticons/confused.png" alt=":?" title=":?" />
<img src="http://chat.ecobytes.net/img/emoticons/glasses.png" alt="8)" title="8)" />
<img src="http://chat.ecobytes.net/img/emoticons/eek.png" alt="8o" title="8o" />
<img src="http://chat.ecobytes.net/img/emoticons/cool.png" alt="B)" title="B)" />
<img src="http://chat.ecobytes.net/img/emoticons/smile-big.png" alt=":-)" title=":-)" />
</div>jsfiddle
发布于 2011-05-23 01:31:57
我认为你需要设置一个指定的高度,而不是自动。http://jsfiddle.net/BN4Ny/这是一个平滑的扩展。不过,我不确定你是否想要那种闭合打开的效果。我刚刚分叉了你的jsfiddle并添加了一个指定的高度。
发布于 2018-08-23 04:09:50
这种解决方案不需要javascript,也不存在需要事先为容器设置固定高度的问题。
这是通过使用max-height属性并将其值设置为较高的值来实现的。
#imgs {
border:1px solid #000;
border-radius:3px;
max-height:20px;
width:100%;
overflow:hidden;
transition: 2s ease;
}
#imgs:hover {
max-height:15em;
}<div id="imgs">
<img src="https://sslb.ulximg.com/image/405x405/artist/1346353449_4159240d68a922ee4ecdfd8e85d179c6.jpg/e96a72d63f272127d0b6d70c76fd3f61/1346353449_eminem.jpg" />
</div>
发布于 2013-08-27 03:40:54
而不是在容器上设置高度或使用JS (这两个都是笨拙的解决方案)……您可以将图像放在列表项中,然后在li上进行转换。
如果所有图像的高度相似,这意味着容器中的内容仍然可以是动态的。例如..。
/*
CLOSED
*/
div.container li
{ height:0px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;}
/*
OPEN
*/
div.container:hover li
{ height:30px;
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-ms-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;}https://stackoverflow.com/questions/6089548
复制相似问题