How can I make a div width to be twice the width of it's min-content.

I think calc shall come into play.
10 Replies
snxxwyy
snxxwyy17mo ago
if your div has a width of min-content i don't believe vanilla css actually allows you to add values even with calc onto it since min-content isn't a numerical value.
croganm
croganm17mo ago
As mentioned, pretty sure that's not quite possible. The only possible way is using javascript. You'd have to set width to min-content, get the computed value, and then multiply it by 2. It's really a horrible way to do something like that but 🤷‍♂️
pinkfrog9
pinkfrog9OP17mo ago
Thanks guys.
snxxwyy
snxxwyy17mo ago
No worries
Asmodeus
Asmodeus17mo ago
Why would you guys not be using transform: scaleX(2); ? and making width min-content @pinkfrog9 have you tried that?
pinkfrog9
pinkfrog9OP17mo ago
ScaleX stretches the text. @coffee_nerd
No description
Asmodeus
Asmodeus17mo ago
can't you just be more specific with your scope and separate the text?
Jochem
Jochem17mo ago
if you've got code to share, that would make helping a lot easier. Check out #how-to-ask-good-questions for tips on how to share your code @pinkfrog9
croganm
croganm17mo ago
Unfortunately I don't believe so unless you want to use absolute and relative positioning. Have the the content and background wrapped in a parent div with position relative. Scale the background, then position the text. However, given all that, I think the point is he wants the text container to also increase in width without scaling the font size
Asmodeus
Asmodeus17mo ago
I'll have a play with it. It's likely very possible, just not common
Want results from more Discord servers?
Add your server