What html or css attribute should I modify so that a mobile browser shows the website with no blank space on the right?


Tags: html,css,mobile,browser,safari

Problem :

I am making a website for mobile devices and It will be fixed 480 pixels width but when I view it on my ipod I see a huge blank space on the right. how can I tell the mobile browser with html / css to show it like a mobile page? I tried

body{width:480px}

and it didn't work



Solution :

Add this meta tag to your page: (do not use the maximum-scale=1 part that many popular ones contain. Zooming is required by some people no mater how nice your page is.)

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

and then you need your mobile layout to be 100% width instead of a fixed width, there are far to many devices with different sizes. Also NEVER check user agent... Ever.

body{ width:100% }

    CSS Howto..

    How to use dp to calculate shadows - web development HTML CSS

    How can I use the CSS pseudo-element :before{ content: '' } to affect an

    How to achieve straight shadow with CSS?

    how to make background-image included via a “class” responsive

    How to wrap div containing spans containing the text to be wrapped?

    How to achieve layout goal - Two Column

    How to appear two HTML input elements in single line (row)

    How can I have a 2 column layout with one of the columns with a fixed width and the other with the remaining width?

    How determine css text of each node in html

    How to select the first element from a selection when one element does not have a class via CSS?

    How i change the dataTables_filter css class

    How to make to div comes the one under the other

    How to add objects in a DIV and appear above the DIV

    How to create fixed sidebar with Skeleton CSS?

    How do I blur an element with scroll, until it's blurred to a certain point?

    How to correct Div overlapping?

    How to get Floating DIVs inside fixed-width DIV to continue horizontally?

    How to make text go over a CSS background img

    How to add image, that overlapping Bootstrap modal?

    How to adjust CSS to make footer fixed height?

    How to center vertically and horizontally a heading text using flask-bootstrap

    How do I hide the div if the Var is empty?

    How to style in IE6 CSS?

    YUI Calendar: how does it load the Sam's Skin CSS?

    How to provide responsive design for svg?

    CSS How to keep bodies of html file and included files from merging?

    CSS--how to detect screen aspect ratio and apply styling accordingly? [duplicate]

    jQuery slideshow with separate div containing image specific text

    how to align in centre using html css

    How to get the “text-justify:kashida” css property effect on to the arabic text excluding IE browsers