221 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
1
vote
1
answer
53
views
CSS calc() differs in Samsung/Firefox vs Chrome/Edge
I’m working with the following code:
<div style="--w: 30px;"></div>
And I’m testing two expressions:
Test Case 1
calc(30px / 720px * 100vw)
Test Case 2
calc(var(--w) / 720px * ...
-1
votes
2
answers
143
views
Calculate width of divided container [closed]
I'm trying to set the width of the striped area in my drawing below, so that it falls within the bounds of the site content.
The width of the content is 80%, with a maximum width of 1080px, and ...
1
vote
1
answer
2k
views
Make a given oklch color 50% lighter via CSS oklch(from ...) and calc() function
We have a design system that comes with a number of CSS custom properties for colors, e.g.:
:root {
--color--blue-1: oklch(88.6% 0.023 238);
}
We're using the relatively new color format oklch.
Now ...
1
vote
2
answers
366
views
How to use a "reverse percentage"/unitless calculation in a CSS calc()? [duplicate]
I would like to use the following calculation in the width and height of an element:
(1 / 0.65) * 100, then the % sign
So that the width & height are set to 153.85%.
However I believe the first ...
-1
votes
1
answer
141
views
Is it possible to use aspect-ratio as part of the calc() in CSS? Or using the element's own width as part of the calc()?
I know that I can use aspect-ratio to make the height of an element equal to a specific fold/portion of its own width, for example aspect-ratio: 1 / 2 will make the height of the element twice as much ...
0
votes
2
answers
291
views
CSS HSL-Triangle
I try to build a website with a color picker.
For that, I would like to use some sort of semicircle with which you can choose the hue and a triangle with which you can choose the saturation and ...
0
votes
0
answers
59
views
Is there a way to convert a unit into another using CSS? [duplicate]
Is there a way to convert a unit into another without using JavaScript?
I thought when I divide a <length> with another <length> unit, the result would be <number>. Such as calc(...
0
votes
1
answer
221
views
Calc with a multivalue css variable [duplicate]
I want to make a hover effect over a p-tag, when hovered the background should get darker. I used filter:brightness(85%) but this made also the text darker. Here is my css.
:root {
--my-color:193 55% ...
-4
votes
2
answers
141
views
How can CSS get the width of a window in px? [duplicate]
I'm currently trying to write code that centers a website for which the content is exactly 895 pixels wide, and I want it to be centered. So, I'm trying to write the following in CSS:
body {
...
...
-1
votes
1
answer
833
views
Pure CSS Line-Height reduction as Font-Size Increases with example but only works in one direction
I found a dynamic way in pure css to reduce the line-height as the font size increases by using a series of nested clamps.
Essentially we ascertain the font size using the em unit and then add the ...
1
vote
2
answers
542
views
Diagonal length of viewport using plain CSS
My goal is to create a absolutely-positioned circle with radius equal to the viewport's (sv*) diagonal length.
I tried calculating the diagonal length of the viewport based on the width and height ...
4
votes
2
answers
924
views
Calculating new value of CSS variable based on existing value
How do I recalculate a new value of a CSS variable (custom property) in a sub-element using calc() to modify the value inherited from a parent element?
This doesn’t work:
div {
height: var(--foo)...
0
votes
1
answer
132
views
Calculate a relative value based on absolute values
I'm building a page and, in other to make it responsive, I'm trying to adjust some values based on the viewport width.
In particular, I have a DIV that I want to split in 2 columns. I'd like those ...
1
vote
0
answers
115
views
Regular Expression to match the value of a CSS calc inside a CSS transform
I'm trying to extract the values of CSS transform strings using this regular expression (\w+)\(([^)]*)\) like translateX(10px) or translateY(calc(-50% - 100px)).
It works great on simple transform ...
1
vote
1
answer
766
views
Change opacity depending on viewport size
I'm trying to change element's opacity based on how wide the browser's window is in a continuous manner. Ideally, I would like to get a unit-less value from calc by dividing current viewport's width ...