Chrome vs. Firefox 😳
For this site:
https://amarlong.github.io/Deichman/frontpage.html
I have the picture set at 70dvh, and it works fine in Firefox (img 1), but not in Chrome (img 2).
This in unchartered territory for me, so not sure how to attack this issue.
Code:
5 Replies
Your image appears to be overflowing the parent (picture) element. This picture element itself, however, does appear to be respecting the 70dvh that you have set.
I can't tell you why this is happening but one solution would be to set the image
position: absolute;
and give the <picture> a position: relative
. This way the image will respect the size of the parent.
But there may be reasons why you can't or don't want to do this.Well, you found a solution, and that's all I needed now. Thank you! 🙏
Where would I look for info about this? I know you don't have the answer, but I really don't understand this, so a bit unsure how to go forward here now.
I think that it has to do with how each browser renders the grid but I can't look into it right now.
Interestingly, uf you had set a row height on the grid it would have worked.
grid-template-rows: 70dvh
so presumably, as it wasn't set, Chrome was setting the row height to match the natural content of, in this case, the image.Why would you put text inside the <picture> element?
You're using it wrong!
<picture> element is there to give you more flexibility over the resources (read: different image size, format, etc.)
https://www.w3schools.com/tags/tag_picture.asp
What you need is <figure> and <caption> tags https://www.w3schools.com/tags/tag_figure.asp
The thing you want to achieve, usually is done by a <div> element (<figure>, <main>, etc). You make it correct size, then set image as a background, and use background-size: cover;
Then, you can place text elements inside and position them.