In the middle of the home page, there are 6 featured posts - 3 in each row. When you resize the screen to a max width of 800px, I want these images to be 2 in a row. I’ve used the following CSS in the media query for max-width: 800px.
For some reason, it’s not working for me. This code is being ignored completely. I can’t see what’s causing this. Can I get a fresh pair of eyes on it?
If yu mean max on min-width media queries then it doesn’t really matter if you use min-width or max-width as the result is much the same these days except that the benefit of max-width is that you don’t exclude IE8 and under to start with.
The min-width approach is that you design for mobile first and then use min-width to target desktops and wider screens but of course then leaves out IE8 (unless you use a polyfill). These days IE8 isn’t much of a concern neither are older handhelds so a min-width approach or a max-width approach is fine.
I prefer the max-width approach when working from converting PSD to html because that is the design you are starting with but on projects that don’t start with a finished design then a min-width approach is fine.
In the end it doesn’t really matter these days as long as you are consistent and use what suits your workflow.
@media only screen and (max-width: 680px) {
.home-middle .featured-content.featuredpage,
.home-middle .featured-content.featuredpost .entry {
min-height: 380px;
min-width: 100%;
}
}
I would typically use max-width, but it wasn’t working. Can you help me understand why? And do you think it’s okay to leave it set to min-width or should I find a way to make it work with max-width?
Also, I noticed that even using min-width, the images are not centered on my Samsung Galaxy S3 phone. They appear to be aligned right instead of center.
Could you give us a test page with you seeing max-width not working? You’ve given us a link but it appears you have gone the min-width route. So a test page with the broken code would be nice. Also give us what browser you are doing it on. If you are saying it’s not working on your smartphone, please note that.
Max-width should be working and there might be something else at play.
The max-width wasn’t working because you still have a width on the element. Change the width to auto or 100% in the media query and it will work. It works with min-width because that forces width to be wider than the width you set. Max-width doesn’t force a width to be wider than the width you set.
Please create your own thread with your own problem. Give a link to the website you are currently working on (and if it’s not live, please use jsfiddle and put your example on there so we can look.)