en.javascript.info icon indicating copy to clipboard operation
en.javascript.info copied to clipboard

Home page counter bug

Open Manik2375 opened this issue 4 years ago • 12 comments

Hi! It seems like in chrome we are getting a bug in homepage, firefox seems fine image

I did a sneak peak, and it looks like every counter is getting same top value perhaps.

Thank you.

Manik2375 avatar Jun 01 '22 17:06 Manik2375

+1 I am encountering this

josephharkins avatar Jun 01 '22 17:06 josephharkins

How can i reproduce it? Are you on Windows?

Here's my Chrome 101 on MacOS 12.3.1:

image

iliakan avatar Jun 01 '22 18:06 iliakan

image

my mistake: UL elements are display: block; by default. that was just the user agent stylesheet


image

ericchase avatar Jun 01 '22 21:06 ericchase

That said. inline-block breaks other things. But I believe this issue is specifically due to a bug in chrome when the UL elements are displayed as blocks.

ericchase avatar Jun 01 '22 21:06 ericchase

Also note that this issue occurs when the elements are split into columns using the css columns property.

The better solution would be to use css grid: image

-I haven't looked into chrome's bug tracker, so I don't know if this issue has been reported or if it will be fixed.

ericchase avatar Jun 01 '22 21:06 ericchase

Ok, I've looked very closely, and now it appears that problem happens when using position: relative; on the element while using position: absolute; on the element's :before pseudo-element.

divs made into columns using css columns: image


the corresponding dom: image


the culprit: image

ericchase avatar Jun 01 '22 23:06 ericchase

@iliakan

I believe we are using Chrome 102. It seems like this bug was just introduced

ericchase avatar Jun 01 '22 23:06 ericchase

A test page to demonstrate the issue:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="robots" content="noindex, nofollow" />
    <style>
        #col {
            column-count: 2;
        }

        #col div div {
            position: relative;
        }

        #col div div:before {
            position: absolute;
            content: '__1';
        }
    </style>

    <title>Using multi-column layouts - example_1 - code sample</title>
</head>

<body>
    <div id="col">
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
        <div>
            <div>a</div>
        </div>
    </div>
</body>

</html>

ericchase avatar Jun 01 '22 23:06 ericchase

chrome 102 on android fails too

joaquinelio avatar Jun 02 '22 00:06 joaquinelio

Wow! I updated to 102 and now I have the bug! Good old times! Browsers introduce bugs, and devs need to work around.

Did you find a good fix, @ericchase ?

iliakan avatar Jun 02 '22 05:06 iliakan

image

Edge 102 🤣

joaquinelio avatar Jun 02 '22 11:06 joaquinelio

A workaround I found, remove position: absolute from ::before

image

Seems like position-relative isn't working in parent... this solution has a problem that bigger text isn't aligned properly, wish we could use subgrid :sweat_smile:

Manik2375 avatar Jun 02 '22 17:06 Manik2375