简体   繁体   中英

centre body of website

I have created a website i have not add stylesheets or coding to make it viewable on ipad or iphone, but when you do view it on ipad, the body the document if offcentre, why is this when it's not off centre on a laptop or pc browser.

I look at some orientation coding to see if that would help but it did nada, can anyone help, i can look online but it been fruitless.

Here's the link to the website: www.mopowered.co.uk, view the source code to see if i am making a mistake, please let me know if i am doing something wrong.

All help is appreciated

<table cellspacing="5" cellpadding="3" border="0" align="center" width="1024">

the align attribute is deprecated, it may be that in the newer browsers?

also I notice you're using text-align: center in the body element which used to center tables maybe still does, anyway it could be the smaller resolution browsers don't like this or a combination of the two, I don't really know..

try the below on the 2 x parent tables

<table cellspacing="5" cellpadding="3" style="margin: 0 auto; width: 1024px; border: 0;">

that's inline styling which is not recommended, if it works you could add a class/ID and add the styles to a stylesheet as it should work the same for PC browsers and mobile devices

Why are you using tables to create a complete website? Use div instead... I believe using divs your website will look better also on iPhone or iPad.
You can do something like this:

// XHTML
<body>
    <div id="container">
        // Your website stuff will go here
    </div>
</body>

// CSS
body {
    // Add some style to the body like background
}
#container {
    margin: 0 auto; // This add no margin to top and bottom and auto center your div
    // Other stuff...
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM