简体   繁体   English

当javascript更改容器大小时,Box-shadow不会正确重新呈现。 (IE9 / 10)

[英]Box-shadow doesn't re-render properly when javascript changes the containers size. (IE9/10)

I recently ran into this issue when cross-testing a design in IE9 and IE10. 我最近在IE9和IE10中交叉测试设计时遇到了这个问题。 Here's a simplified version of it on codepen. 这是codepen上的简化版本。 http://codepen.io/jimmykup/full/DHeBC.com (and here's a screencap of the issue in action: http://i.imgur.com/xEQ52.png ) http://codepen.io/jimmykup/full/DHeBC.com (以下是该问题的屏幕截图: http//i.imgur.com/xEQ52.png

  1. First jQuery appends some HTML to the container. 首先,jQuery将一些HTML附加到容器中。
  2. When you hover over the container, I use .remove() to get rid of that same HTML. 当您将鼠标悬停在容器上时,我使用.remove()来删除相同的HTML。
  3. Because the HTML is removed, the parent container (with the box-shadow) changes in height. 因为删除了HTML,所以父容器(带有box-shadow)的高度会发生变化。
  4. In IE9+ the box-shadow stays with the container, but it also leaves behind a second shadow where the box use to stretch to. 在IE9 +中,盒子阴影留在容器中,但它也留下了第二个阴影,盒子用来伸展到。

Everything works fine in the latest versions of Firefox, Chrome and Opera. 在最新版本的Firefox,Chrome和Opera中,一切正常。 IE9 and 10 are the problem. IE9和10是问题所在。

Just cause a repaint on the element with the drop shadow. 只需使用投影在元素上重新绘制。 To cause a repaint change the z-index. 使重绘更改z-index。 In your case add this in your $('form').hover after the remove. 在你的情况下,在你的$('form').hover添加它$('form').hover在删除后$('form').hover You can change it to what z-index was previous with the code below or simply set it to 1. 您可以使用下面的代码将其更改为之前的z-index,或者只需将其设置为1。

$('#lightning-deal').css('z-index', $('#lightning-deal').css('z-index'));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM