I’m stuck.
Looking to add images to a flex box. I’ve inserted divs and then placed and image inside of each div.
Can’t seem to get the image to fill the div so it looks like a grid and not random sized images…
I’ve looked over the forums… not keen to import every photo to size, I’m wanting it to fill with hidden overflow when I update images from time to time.
Having an image filling a div happens naturally if you’re using the images as CSS image-backgrounds. But that’s not ideal as they’re not considered as images by HTML anymore, hence not having an alt tag etc.
CSS comes with a handy property, that is not yet supported by Webflow (but I hope it will one day soon). It’s the _ object-fit_ property.
Check the last demo at the end of my clipping and masking demo page.
I think what you need is this simple line of CS code: .fit { object-fit: cover; }
So you could try to paste the following full code in a custom code component INSIDE of the page (so you can see the effects right in the Designer):
There should be no problem adding custom code to sites not hosted on Webflow, it’s just done differently. I haven’t exported a site yet, but there will be a file included for CSS - just add the bit from @vincent to the very end.
Additionally, I believe you can follow the steps above before exporting the site and the changes should be retained. Anyone more familiar with this process may have some different information but that should get you started.
beauty thanks, I’ll have a play.
I don’t get the option to insert html into the pages, perhaps I just can’t find it. I’m looking in the + column where you would ad a div or container etc… nothing there. Is it located somewhere I can’t find? I searched the forum but I might be having an off day…
I’ve got the plan I want and it looks like I’ve got the solution. I haven’t had to add the CSS as you’ve suggested yet but I’ll hold onto that idea for future reference, thanks for your expertise.
It seems to have worked with the DIV set to Flexbox
Great, elegant! Only downside is if you have a very short imge in height, like a panoramic, it’s not going to fit and cover all the div. Very easily fixed, you just have to add this to your images class:
Thanks for the answer @Vincent Does this method make it so you still download the whole image? I’m looking for something just like this but where it also “crops” away the unseen parts so it does not waste bandwidth.
I’m trying to do this for mobile issues I am having: The images crop when on mobile and do not fill the entire Div they are placed in (which is what I need to happen):
Thanks for the reply. Unfortunately, on published its still giving me issues. On the screenshot you can see that on the left and right of the image, the divblock is showing - this of course cascades down through the other breakpoints
Hmmm… I tried this but Webflow produces an error. I filled out the error report and sent it to Webflow but will see…
My problem is pulling the images from the CMS and they are all of different proportions, wanting them to fill up the space, much like the original poster.