Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Div with fixed width rendering too wide in ipad

Tags:

html

css

ipad

I'm trying to optimize one of my pages for iPad. You can see my test-page here: http://demo.dennismadsen.com/ipad/

It contains a black box with a width of 800px. When I see it on my iPad and take a screenshow, I can see, that the box is more when 800px width - about 837px: http://demo.dennismadsen.com/ipad/screenshot.png

I'm wondering why this is happening?

like image 497
dhrm Avatar asked Feb 17 '11 16:02

dhrm


People also ask

How do I force a div aspect ratio?

In the HTML, put the player <iframe> in a <div> container. In the CSS for the <div>, add a percentage value for padding-bottom and set the position to relative, this will maintain the aspect ratio of the container. The value of the padding determines the aspect ratio. ie 56.25% = 16:9.

How do I set fix width?

To convert it to a fixed-width layout, simply add a fixed with to the #wrapper and set the margins to auto. Setting the margins to auto will cause the left and right margins to be equal no matter how wide the browser window is, which will cause your fixed-width layout to be positioned in the center of the browser.

What is max-width and width in CSS?

The CSS height and width properties are used to set the height and width of an element. The CSS max-width property is used to set the maximum width of an element. This element has a height of 50 pixels and a width of 100%.


1 Answers

Regardless of the actual width of your website and its elements, iOS devices will try to scale your content for optimum viewing.

Stop that happening by putting this in your HTML header:

<meta name="viewport" content="initial-scale=1.0;">
like image 145
Kalessin Avatar answered Sep 29 '22 01:09

Kalessin