Skip to main content
Ask A Question
You’re not receiving notifications from this thread.

Possible to get img elements to be the size of container and behave like background-image?

General • Asked by DomnikBritto

I’m using a grid for a complex layout and I would like the images in it to have no control over size. The grid is set using fr unit s so that it too will not have an actual height, but instead just fill the space of its container.

I’ve set the images to 100% which fills the cells, but their ac mobdro tual pixel dimensions still have control over the the grid. I would expect the grid to collapse completely when there’s nothing in it that has an explicit height, but this is not what happens. The images intrinsic size still exerts some control.

It does work when I set images using background but that’s semantically incorrect for my use case.

Is this possible?

Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 31,353+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.