我使用-webkit-transform (和-moz-transform / -o-transform)来旋转div。还添加了固定位置,以便div随用户向下滚动。
在Firefox中,它工作得很好,但在基于webkit的浏览器中,它就坏了。在使用-webkit-transform之后,固定的位置不再起作用!那件事怎么可能?
发布于 2016-06-22 04:16:28
CSS Transforms spec解释了这种行为。具有变换的元素充当固定位置后代的包含块,因此具有变换的对象下的位置:固定不再具有固定行为。
当应用于相同的元素时,它们确实起作用;元素将被定位为固定的,然后进行转换。
发布于 2013-07-21 23:02:49
对我有效的一些(有点老生常谈的)东西是position:sticky
:
.fixed {
position: sticky;
}
发布于 2014-01-14 07:43:22
对于任何发现他们的背景图像在Chrome中消失的人来说,因为背景-附件:修复了相同的问题;-这是我的解决方案:
// run js if Chrome is being used
if(navigator.userAgent.toLowerCase().indexOf('chrome') > -1) {
// set background-attachment back to the default of 'scroll'
$('.imagebg').css('background-attachment', 'scroll');
// move the background-position according to the div's y position
$(window).scroll(function(){
scrollTop = $(window).scrollTop();
photoTop = $('.imagebg').offset().top;
distance = (photoTop - scrollTop);
$('.imagebg').css('background-position', 'center ' + (distance*-1) + 'px');
});
}
https://stackoverflow.com/questions/2637058
复制相似问题