Responsive sizes handling `min-width`
See original GitHub issueDescribe the bug
Hi, I would like to load a bigger image on mobile and smaller on desktop. Normally I would define on img
HTML tag a min-width
or if needed both min and max like so:
sizes="
((min-width: 50em) and (max-width: 60em)) 50em,
((min-width: 30em) and (max-width: 50em)) 30em,
(max-width: 30em) 20em"
But the component accepts only max-width
and it won’t work in my case, where the bigger images should be loaded on smaller screen. Currently my code looks following (smaller images are loaded on both mobile and desktop):
responsive={[
{
size: {
width: Math.round(cover.width / 2),
height: Math.round(cover.height / 2),
},
maxWidth: 768,
},
{
size: {
width: Math.round(cover.width / 4),
height: Math.round(cover.height / 4),
},
maxWidth: 1200
},
]}
Am I missing something or it can work as I expect it with the current implementation of Remix-Image
?
Your Example Website or App
No response
Steps to Reproduce the Bug or Issue
Define in responsive
prop two image sizes: for mobile bigger images should be displayed and for desktop smaller ones.
Expected behavior
I would like to defined also a min-width to display images.
Screenshots or Videos
No response
Platform
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
Additional context
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
responsive website min-width? - UX Stack Exchange
First: You can have a great responsive site loaded with min-widths or max-widths or even mix them ...
Read more >Setting a minimum width to fit on responsive website
The min-width will override the width value (as you would expect) when the 100% width falls below 480px.
Read more >Responsive web design basics
A common way to deal with this problem is to give all images a max-width of 100% . This will cause the image...
Read more >Media Query CSS Example – Max and Min Screen Width for ...
In this article, I will talk about how to use responsive design and media ... @media (min-width: 600px) and (max-width: 768px) { body ......
Read more >min-width - CSS: Cascading Style Sheets - MDN Web Docs
The min-width CSS property sets the minimum width of an element. It prevents the used value of the width property from becoming smaller...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Maybe we need to sort by
maxWidth
instead? From the smallest to largest and values withoutmaxWidth
at the end? I created pull request: https://github.com/Josh-McFarlin/remix-image/pull/34/files@tomekrozalski Thanks for the PR! Currently relocating for work, so I’ll review it later today and hopefully push out a new release.