简体   繁体   English

在父容器的动画期间,绝对定位的子元素被剪裁

[英]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.

相关问题 如何快速找到绝对定位的子项的相对定位的HTML父元素? - How can I quickly find the relatively positioned HTML parent element of an absolutely positioned child? 相对定位元素内部的绝对定位元素被裁剪 - Absolute positioned element inside relative positioned element gets clipped 如何防止父容器滚动定位为固定的子元素 - How to prevent the parent container from scrolling the child element positioned as fixed Javascript根据多个绝对定位的子元素的高度调整容器的大小 - Javascript to resize container based on height of multiple absolutely positioned child elements 将父div扩展到最高定位的子项的高度 - Expand parent div to height of TALLEST absolutely-positioned child 垂直居中,绝对定位的子力父高度匹配 - Vertically centered, Absolutely positioned child force parent height to match 绝对定位的子div的父div拒绝100%的高度 - parent div with absolutely positioned child divs refuses to be 100% height 通过 javascript 将绝对定位的子代居中到没有定位的父代 - Centering an absolutely positioned child to a parent with no positioning via javascript React应用,绝对定位的子对象未相对于其相对定位的父对象定位(在Chrome中) - React app, absolutely positioned child not positioned relative to its relatively positioned parent (in Chrome) 绝对定位元素的宽度 - Width of absolutely positioned element
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM