[英]Absolutely positioned child element gets clipped during animation of parent container
I created a box that grows on hover. 我创建了一个在悬停时生长的盒子。 The box has a thumbnail inside it that is
position:absolute
and bigger than the parent box. 该框内有一个缩略图,其
position:absolute
且大于父框。
When I animate the width or height of the parent container, the thumbnail gets cropped to the size of the parent, but only during the animation. 当我为父容器的宽度或高度设置动画时,缩略图会被裁剪为父级的大小,但仅限于动画期间。
See here for a simple demo (tested in chrome/safari/ff on mac): http://jsfiddle.net/Q2BPx/3/ 在这里看一个简单的演示(在mac上测试chrome / safari / ff): http : //jsfiddle.net/Q2BPx/3/
What am I doing wrong? 我究竟做错了什么?
I don't know that you are doing anything "wrong" per se. 我不知道你本身做了什么“错误”。
When the animate method is running jQuery uses inline style to set the width for each frame of the animation. 当animate方法运行时,jQuery使用内联样式来设置动画的每个帧的宽度。 It also adds the style "overflow: hidden" into the inline style.
它还将样式“overflow:hidden”添加到内联样式中。
You can hack the css of expander by adding: overflow: visible !important; 您可以通过添加以下内容来破解扩展器的CSS:overflow:visible!important;
This will prevent the inline overflow: hidden from making your thumbnail being cropped. 这将防止内联溢出:隐藏使缩略图被裁剪。
But, you might want to look into the jQuery code to see why animate is using the overflow setting. 但是,您可能需要查看jQuery代码以了解为什么动画使用溢出设置。
Or, at least test your page to make sure you have not introduced an anomaly by using the overflow: visible !important; 或者,至少测试您的页面,以确保您没有使用溢出引入异常:visible!important;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.