::before CSS between browsers is off

This topic contains 2 replies, has 2 voices, and was last updated by  andrewpeters 1 month, 1 week ago.

Author Posts

andrewpeters

Hey guys, made a quick video to explain my situation: https://www.loom.com/share/4667bee0c6de4d0f8a48b27e0bcb9a7f

Here’s the code I’m using:

/*H1 Heading Highlights*/
.green-text {
position: relative;
z-index: 9;
}

.green-text::before {
content:"";
z-index: -1;
display: inline-block;
top: 50%;
position: absolute;
bottom: 1px;
margin-left: 4px;
padding: 16px;
width: calc(100% + 2px);
background: #B1C63A;
border-radius: 10px;
transform:  skewX(-20deg);
}

Sebastian

Hmm, I can’t see anything wrong with your CSS. But it looks like there is an issue with the width of the green area. Also, is top:50% necessary? Could you leave that out and have height: 50%? Just a guess, but setting both top and bottom can sometimes lead to less predictable results.

Also might be worth trying display: block on the main element e.g.

.green-text {
position: relative;
z-index: 9;
display: block;
}

But all this is guessing, I would normally ask for a link to the page to work out what’s going on, but I see you’re working on a local .dev site.

Cheers,
Sebastian


andrewpeters

Solid. Thanks Sebastian!

You must login or register to reply to this topic.