Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Width 100% not working on iOS

Tags:

css

ios

For some reason on the iphone, my footer doesn't stretch across the screen, even though it's css is set to width: 100%. You can view an example of my footer issue here: http://pixelcakecreative.com/tla2/

My css for the footer is as follows:

#footer{ width:100%; margin-top:100px; position:relative; clear:left; background:#4c4c4c; float:left; padding:30px 0;}

This problem ONLY applies to iOS devices, as the layout works fine on PC browsers. Any idea how to fix this? I have tried everything I can think of. Thanks!

like image 946
JCHASE11 Avatar asked Jan 17 '12 03:01

JCHASE11


People also ask

Should you use 100% width?

In many cases, applying width: 100% to a block level element is either unnecessary or will bring undesirable results. If you're using padding on the inner element and you use box-sizing: border-box , then you'll be safe.

Is width 100 and width 100% the?

Answer is No. cause 100 is pixels and 100% is percentage of overall size of page.

Can we give width more than 100%?

Yes, as per the CSS 2.1 Specification, all non-negative values are valid for width, that includes percentage values above 100%.

What does width 100 percent do?

On the other hand, if you specify width:100% , the element's total width will be 100% of its containing block plus any horizontal margin, padding and border (unless you've used box-sizing:border-box , in which case only margins are added to the 100% to change how its total width is calculated).


1 Answers

Try by simplifying your meta name viewport (at least for iOS) to the following line:

<meta name="viewport" content="width=device-width,initial-scale=1" />

Less attributes than you are normally told to have, I know, but it has worked for my mobile projects.

Now, upon closer inspection, the majority if your site is under 'center', and then you have wrapper and footer.

The code used for the wrapper and the footer is different. Wrapper has a fixed width:941px; whereas footer just has width:100%. The majority of the elements inside wrapper have width:100% but that only works because wrapper has width: 941px.

So, you either try adding that same width and padding to footer {width:941px; padding:30px 34px;} or something along those lines OR

You throw footer inside a similar wrapper with a fixed with, padding, etc and then let let footer keep width:100%;

like image 166
Capagris Avatar answered Oct 05 '22 23:10

Capagris