question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS opacity capped at 1% when using percentage units

See original GitHub issue

Do you want to request a feature or report a bug?

bug

What is the current behaviour?

CSS opacity with units as a [percentage] is capped at 1% for production builds.

If the current behaviour is a bug, please provide the steps to reproduce.

Minimal example: https://github.com/jennydaman/opacity-onepercent-bug/commit/c98943de9f8b90df501f5a2690498d7f21d7ec5c

Repo above was created using preact create --yarn --git default preact-opacity-bug

Screenshot

yarn run build && yarn run serve

What is the expected behaviour?

opacity: 67% or whatever

Please mention other relevant information.

I think this might be a bug with webpack’s css-loader, however I am unfamiliar with the code base (both preact-cli and css-loader). I’m hoping for a pointer on where this bug report should be made to or hints on how to trace/isolate the bug.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
rschristiancommented, May 27, 2020

so do we need to bumpsome of our dep and re-release?

Well currently there’s nothing to bump. The lib author just says a fix “will be released soon”. The fix was merged back on Feb 21, so “soon” is pretty vague, as the fix has already been around for 3 months without a release to make that fix public. In the meantime, the author suggests using postcss-ignore-plugin to ignore it, or just disable the plugin (cssnano) outright.

However, opacity with percentages as units isn’t even supported across the board by browsers, so there’s always the possibility of ignoring this for a bit. Don’t know how much effort anyone wants to put into fixing something that already won’t work on a significant portion of the internet anyways.

2reactions
rschristiancommented, May 25, 2020

The bug stems from an issue with cssnano, which is used by optimize-css-assets-webpack-plugin. It’s known and been fixed, just waiting on a new release. A workaround is offered, but if the fix is released soon enough, it might not be worth doing.

Here’s the PR in which it has been fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to define Opacity by percentage in CSS? - Stack Overflow
Using a percentage is fully valid css, according to the spec: https://developer.mozilla.org/en-US/docs/Web/CSS/opacity#Values.
Read more >
opacity - CSS: Cascading Style Sheets - MDN Web Docs
The opacity CSS property sets the opacity of an element. Opacity is the degree to which content behind an element is hidden, and...
Read more >
CSS Values and Units Module Level 4 - W3C
Abstract. This CSS module describes the common values and units that CSS properties accept and the syntax used for describing them in CSS...
Read more >
Sizing Units - web.dev
In this module find out how to size elements using CSS, working with the flexible ... The ch unit is one of a...
Read more >
JavaFX CSS Reference Guide - Oracle Help Center
These are a percentage of some length, typically to the width or height of a node. <number>[ % ]. <angle>. An angle is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found