grid-template-columns, Chrome v. Firefox, Firefox stretching col width, Chrome keeping to content
.photos_div_right is mapping divs which contain <img/> elements:
Leaving grid-template-columns unset, Chrome defaults to content width, while Firefox (as well as iPhone) wants to stretch the columns. Most attempts at setting
grid-template-columns
are being flagged by Firefox as 'invalid values'.
Has anyone come across this issue before? Alternatively, I'd also tried controlling column width by way of just setting the grid cell widths (the > div{}
) explicitly, but have had similar trouble keeping these widths to the responsive width of the child image.11 Replies
Do you have height/width attributes on your images?
its always recommended btw helps with paint but browsers like to render images different and without the height/width attributes FF will act funky in my experience.
Tip: Always specify both the height and width attributes for images. If height and width are set, the space required for the image is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the image, and cannot reserve the appropriate space to it.
the images are rendering in the same way, same widths, behaving uniformly across browsers, but this is their setting:
Since you are also not setting columns the grid is being affected
no in html
<img height="300" width="350" alt="" ... />
then keep what you have in css ofc
but you need to give the attributesSmashing Magazine
Setting Height And Width On Images Is Important Again — Smashing Ma...
To prevent layout shifts and improve performance scores, we need to always set width and height attributes on our images. Here’s why and when it matters.
So the grid container (
.photos_div_right
) which contains the child div grid items, which themselves contain the <img/> elements, is itself a child of .photos_div
. Here is a wider view:
And this .photos_div container, has a responsive height and width:
This container responsiveness is affecting .photos_div_left
(its grid container child)'s height, which is in turn affecting the sizes of its grid cell divs' heights.
no height/width attributes*
again read what I wrote
read teh smashing article too
right no i get what you're saying, i'm just wondering how to achieve this same respnsiveness if I'm hard coding a width in the html
you just keep the same css
but I would never use vh/vw with sizing (oh thats your parent div but still avoid it)
The smashing article goes over it though, you set the attributes and then still set the sizes you want in css
okay, i'll give it a read
thank you
np I hope it helps even if its not the solution (which I'm betting it is) its something you should be doing.
right i gotcha