Why do Safari and Firefox seem to incorrectly render my gradient and how can I fix it?

Curtis Blackwell

Here's the code on CodePen. It looks exactly as I expect in Chrome. Firefox and Safari both look wrong. (I'm on the latest versions of all 3.)

I'm working on a way to use a constant gradient background across multiple inline-block elements. Here's how it's working right now:

  1. I have a parent ol whose :before pseudo-element has a gradient background (transparent to opaque color) and a z-index set to display it above the child lis.
  2. The lis have the background-color set to the color that looks like what the gradient's transparent value is set to.
  3. The li's color is set to transparent and have :before pseudo-elements that display the text that's previously set to transparent and have their z-indices set to display above the ol:before (with background gradient).

The problems I'm seeing in Firefox:

  1. The gradient looks like it's got 3 color stops (transparent, grey, transparent) instead of the 2 that are set.
  2. The gradient seems as though it's got a multiply blend mode set.

The problems I'm seeing in Safari:

In addition to the same problems in Firefox, it also displays two gradients which seem to have multiply blend modes. One from -webkit-linear-gradient and one from linear-gradient. Solving the issue of the apparent blend mode should take care of this third issue, though.


My googling made me aware of background-blend-mode, but setting that to normal (or any other valid value) changed nothing. I think it only works with multiple backgrounds on a single element, but I'm not sure about that. However, that would explain why it doesn't solve my problems.

Curtis Blackwell

The problem was that I used the keyword transparent rather than a transparent version of the color that it was gradating to. The browsers that didn't render the gradient as expected were treating transparent as transparent black. That meant that different gradations between black and my color were present in the gradient.

I'm using SASS so the fix is pretty simple: Just use the rgba() function to convert my hex color to rgba.

background-image: linear-gradient(to top right, rgba($brand-primary, 0), $brand-primary);

I updated the code on CodePen to show the solution.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why my output is "()" and how can i fix it?

Why are my Firefox Menu Arrows Enlarged? How do I fix them?

How can I fix my problems with fonts in Firefox?

why do I get this error, how do can I fix it

Safari zoom causes problems in my donut circle display, what can I do to fix this?

My Xcode keeps sending an error and I can't seem to fix it

Why does my Makefile not compile and how can I fix it?

Why is my split view behaving like this and how can I fix it?

MathJax is duplicating my equations -- why and how can I fix this?

Why is my CNN overfitting and how can I fix it?

Why is JavaCC not working on my mac and how can I fix it?

Why html skips my variable and how can I fix it?

Why is my actionbar not showing and how do I fix it?

Why is my while going in a infinity loop? How do I fix it?

Why are months in my date slicer repeating? How do I fix it?

Why do I get this error and how can I fix it? Swift

How can I fix the error incorrectly set FixedData property within the TablixRowHierarchy when I deployed my report in SSRS?

Render error in CoordinatorLayout - How can I fix that?

How can I make VSCode render my HTML file on firefox whenever I run it

I want to remap my keyboard to work like my Macbook Air, but I have tried and can't seem to - how do i do it?

I was trying to create randomly positioned objects that should not collide. My collider does not seem to detect properly. How do I fix it?

I can't seem to generate a migration for my rails app, how do I get past this error?

Why chrome doesn't (seem to) need Flash while Firefox and Safari do?

I can't seem to make navigation drawer work: how to fix this?

How do I render my partialview inside my main view or can I update the values in another way?

How do I fix? DOM javascript gradient not working?

Just upgraded to macOS Catalina, how do I fix my Firefox Nightly appearance (red background, blurry text)?

Why does adding margin to my table move donw my sidebar and how can I fix this?

If my OEMCP is set to 437 then why is my cmd.exe default codepage 932? and how do I fix this?

TOP Ranking

HotTag

Archive