Odd behavior of :first-letter in Chrome

前端 未结 3 710
滥情空心
滥情空心 2021-01-21 10:08

Adding what seems to be an innocuous class to an element having a class containing :first-letter causes the first letter, under some circumstances, to be rendered incorrectly. A

3条回答
  •  一生所求
    2021-01-21 11:02

    You've done nothing wrong. Apparently Chrome has decided that for version 41, it'll screw up repainting the :first-letter pseudo-element (incidentally, Chrome is notorious for repaint bugs). If you declare the "menuitemon" class in the markup, it has no trouble rendering the pseudo-element with the negative margin. It's only when you add it dynamically that it screws up.

    Fortunately, unlike the cascade resolution bug that affected Chrome 39 -> 40, I was able to work around this very trivially by using a negative text-indent on the element instead of a negative margin on :first-letter:

    p.unindent {
        text-indent: -20px;
        /* ... */
    }
    
    /*
    p.unindent:first-letter {
        margin-left: -20px;
    }
    */
    

提交回复
热议问题