Content width + some amount of px with calc()

Viewed 12007

I know i can do calc(100% + 15px), but is there way to do calc("content width" + 15px)?

fit-content and auto didn't work, which kinda makes sense.

I have unknown number of items that i want just to take width they need (inline-block) + some amount of px for justify-content: space-between;

If this can't be done with calc, is there an alternative?

(I'm using scss if that changes anything)

2 Answers

Use padding. The content+padding => determines size without using % percentage for width.

In my scenario, a button added a '>' using pseudo ::after, and was positioned 18px from the right edige.

I also found myself in this situation, unfortunately not having found a solution I used a small JS function that assigns the value

width: calc ($(element).width() + 10px);

Unfortunately, rather than calculating the measure via javascript when loading the page I can not help you.

Related