August 20, 201214 yr We're in the process of creating our first responsive website (http://27.131.69.118/~chris/ - this is a production site, so excuse the mess!), but having some issues with backgrounds/divs not spanning the full width of mobile devices. The site features three different styles - desktop, tablet and mobile. The mobile version produces an issue I've encountered before, but am unsure how to rectify. Towards the bottom of the site, there are two areas (main-bottom and footer) that don't span the width of the screen when viewed on a phone. Our viewport tag is as follows: <meta name="viewport" content="width=device-width"> If I set the width property to 480, the backgrounds and content fill the entire screen. However if I use "device-width", the backgrounds don't fill the screen. I've found a couple of solutions online that suggest setting body and html elements to {margin: 0; padding: 0; width: 100%;} but so far this hasn't yielded any results. I'm sure it's something that will be blindingly obvious, but I just can't figure it out. Anyone have any suggestions? Cheers, Chris
August 20, 201214 yr This site http://www.html5rock...espeed=noscript recommends <meta name="viewport" content="width=device-width, initial-scale=1" /> and this site http://kyleschaeffer...-media-queries/ recommends <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" /> and I use <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> I really don't know what the difference is. I hope that they are just variations of the same thing. I haven't had your problem so I can't reproduce it, but perhaps one of the above meta tags will cure it. I also have a site where I want a full width footer and I added width: 100%; to the footer container and I don't get your problem. What happens if you add width: 100%; to the #footer-container style in the mobile stylesheet? I never set a width to the body as it's supposed to be 100% by default and I note that you have commented out width: 100%; in the mobile stylesheet. Edit: I've tested with Opera Mobile Emulator for HTC Evo 4G 480*800 and I could see the black background only covered part of the width. I looked at the zoom settings and noticed that it was set at 150% by default. When I changed it to 100% everything fitted the viewport. I don't fully understand how mobile zoom settings work but have you tried altering the zoom in the mobile you are using? I notice that you have your main stylesheet links, then media queries with min-width for 960px, then min-width: 481px and max-width: 959px; then max-width: 480px; The first link I posted above suggests that you code your main stylesheet for 480px mobile phones, then have the min-widths for large widths and not have a separate media query for 480px. However, I don't think this would make any difference in your case. Edited August 20, 201214 yr by Wickham
Create an account or sign in to comment