How can I force WebKit to redraw/repaint to propagate style changes?

后端 未结 27 2692
我寻月下人不归
我寻月下人不归 2020-11-22 02:04

I have some trivial JavaScript to effect a style change:

sel = document.getElementById(\'my_id\');
sel.className = sel.className.replace(/item-[1-9]-selected         


        
27条回答
  •  轮回少年
    2020-11-22 02:28

    The only solution works for me is similar to sowasred2012's answer:

    $('body').css('display', 'table').height();
    $('body').css('display', 'block');
    

    I have a lot of problem blocks on page, so I change display property of root element. And I use display: table; instead of display: none;, because none will reset scrolling offset.

提交回复
热议问题