That’s because mobile devices shrink to fit if they don’t have the proper media query. Add this in and it will allow the browsers device width to be used (which will trigger mobile since it’s small)
This is a step in the right direction. This is how you should be coding. Give it a shot. You need to be coding like this. Long gone are maintaining multiple sites for diffferent screens.
Each picture is contained in a <li> which is a block element. So for big screens I float them left and make the width small enough to fit 3 per line. 33% or something (I think I do 32% and 1% margin IIRC). So then the image I made 100% height and width so it shrinks/expands.
Then when it comes to small screens, I simply unfloat the <li>'s so it appears once per line. Then I center it on screen. The main thing is just htat I unfloat it. Don’t overthink it
You can probably just move your media queries to a separate external CSS file (not combined with your large screen code). Then use PHP to ONLY include that file IF the mobile GET variable is not found. I’d do it like this
if(!isset($_GET['mobile']))
{
//display mobile stylesheet
}
I think I would have automatic recognition of mobile devices on all pages (page width with @media).
The link to the desktop version of the site would only go to the homepage.
So that means only the index page needs to be php. This is correct, right?..WRONG! However when someone clicks to go to another page it would show the mobile site again! Sounds a bit complicated. I will probably limit users to only being able to use the mobile version…this is what you do, right?
Yes that’s what most people do. An option for Desktop version is just icing on the cake. Actually, I assume that if people would want the desktop version…you could just only add in the meta tag if people clicked that link. Instead of including/excluding the CSS file, just include/exclude the meta tag.
This really is the wrong approach for small to medium sites. These days there’s not a ‘desktop site’ as such because of the myriad of devices out there and indeed should I close the window on my desktop site I would want the content to fit in the window and not be squashed or have a scroll bar present. Remember there are many tablets out there now that range from very small to almost desktop size so this is not just a mobile versus desktop question.
Just design for all devices by creating a flexible layout and throw in a media query when the design looks awkward or doesn’t fit. With a few well placed media queries and a well structured html you can accommodate all devices without ever knowing anything about them. No need for separation of code or multiple device chasing. You can remove content in the smaller screen version but think carefully about why you are doing this. If the content wasn’t important then why include it in the main site?
I am redeveloping my website and I currently have a <div id="navigation"> which has a width of 970px. I need this to change when using a mobile device (with less in the navigation bar). I tried removing the width completely and the navigation will not display inline now. Do you know how to either change the width of the navigation div in the @media or can I display:inline; without specifying a width of the div?
By default, on all screens, small through extra large, the width is 970px (it should be a fluid value and not px but that’s another day…)
So no matter what, you will get 970px. Now, you want to change the value or remove it for mobile. How do you do this? Think this through. You still need to understand media queries. You obviously can’t remove the default 970px for all screen sizes. That’s not hte answer. That breaks everything.
Hint: Update the value in the media query. BUT TO WHAT? Not another pixel value. Not percentage. Not em. Not any value based answer.
See, already customizing. You are on your way to becoming an expert . Welcome to the world of responsive design. THIS is what you should be doing for websites. Ideally you shouldn’t need many media queries. Your entire site should basically be fluid and it should shrink down pretty well without queries. However, customizing (like I did with my portfolio page it make it single column) is good to make it more aesthetically pleasing.
tl;dr - make site fluid, and do queries where needed to make mobile view more enjoyable.
You shouldn’t need the width:auto; if you are making it display:inline. If it is inline, then it won’t accept a width to begin with. No matter if it’s set already. It’s now an inline level element and they don’t recognize widths. Try removing width:auto;. Just nitpicking - you got it working
You’d need to manually go into the query and change the (pixel/percent/em/rem) value. There are no preset size settings, unless you look into frameworks, which I’m not sure if you need or not (you seem to be getting along fine without it, and I’d recommend you not do it for this site so you can learn more.)