Lazyweb CSS question: How do I do this?

background-size: $image_is_smaller_than_box ? auto : contain;

I.e. contain the background image in the box, but don't upscale if the image is smaller.

@ayo personally I would use 2 div, one inside the normal one, and I would play with min / max size

@Miaourt That only seems to work if you know the size of the image and the outer div beforehand. But if you know that, you may as well just use a single div and set the `background-size` appropriately.

(Currently I do know both sizes so this works for me, but it's... meh. Going to be a pain if I ever decide to make the box dynamically sized)

Sign in to participate in the conversation

A lonely little town in the wider world of the fediverse.