Modifying a webpage so it's more mobile/tablet compatible

css, html

Solution

There are several ways to accommodate Mobile/Tablet devices with your website.

FIXED DESIGN

Create a stylesheet that works generically across all formats. Your site will appear the same on all devices but this process will be the simplest solution.

The fixed design process should primarily use percentages and max-widths to create content that changes based on the device width.

PROS

When used well this process uses least resources and is faster to create and modify.

CONS

If your site has large amounts of content on a page then your site can become very cramped on smaller devices

RESPONSIVE DESIGN

If you want your site to be viewed differently and arguably optimally on different devices then you need a responsive design. This can be achieve by using a dynamic stylesheet or by using multiple stylesheets for different devices.

PROS

A very versatile website that can be display uniquely and optimally based on the viewing device.

CONS

Larger or additional resources and marginally longer loading depending on design. Longer development and modification times.

CREATING RESPONSIVE CASCADING STYLESHEETS

It is no longer practical to use set width becuase there are simple to many varible sizes. The answer is flexible everything.

Using a viewport metatag as in your example to target the device that is accessing your website.

`<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>`

There is clearly demand for the viewport meta tag, since it is supported by most popular mobile browsers and used by thousands of web sites.

Using media queries.

Media Queries let you write individual rules for specific screen widths.

/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px)
and (max-device-width : 480px) {
/* Styles */
}

/* Smartphones (landscape) ----------- */
@media only screen
and (min-width : 321px) {
/* Styles */
}

/* Smartphones (portrait) ----------- */
@media only screen
and (max-width : 320px) {
/* Styles */
}

- Using Javascript.

A good javascript solution other than bootstrap is jquery mobile which takes away the time and effort of designing a responsive site by doing the work for you. You do not need to know or edit any javascript to use it.

SPECIFICS

So now we have the options lets take a look at your specific issue. Your website actually seems very responsive already. and is well laid out for both mobile and PC using the fixed design.

CHANGE YOUR MEDIA QUERIES (They wont work without brackets)

FROM

@media screen and max-width 600px {
    .headimager {
        display: none;
    }
}

@media screen and max-width 450px {
    .footimager {
        display: none;
    }
}

TO

@media screen and (max-width:600px) {
    .headimager {
        display: none;
    }
}

@media screen and (max-width:450px) {
    .footimager {
        display: none;
    }
}

I would advise against using a table (#gradient-style). A simple 100% div (#container) will do the trick with floated or %width nested elements. Also the text in container wont auto wrap without spacing of css wordwrap:break;

Other than that there are no more noticeable problems but please do add a comment if you require specific changes.

Problem

SO, I'm looking for some help making a fairly simple page more mobile/tablet friendly as currently on certain mobile devices it appears pretty ugly :S I've tried positioning stuff correctly and used pixels rather than percentages because I'm only really doing stuff in each corner (top and bottom bars) and I've attempted on incorporating some scaling aswell as code to make the images not display at certain screen width's Can anyone help correct my html/css so that it's fully compatible as it never quite works when I make changes. HTML: ``` <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="true" name="HandheldFriendly" /> <meta content="width=device-width" name="viewport" /> <meta content="width=device-width,initial-scale=0.75" name="viewport" /> <title>Website.com</title> <link href="testing.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="header_container"> <div id="header"> <div class="headimage"> <a href="http://website.com/" target="_blank"> <img alt="" class="headimager" src="http://placehold.it/350x95/" /> </a> </div> <select class="class-selector"> <option value="">- Testing Dropdown -</option> </select> <div class="classcycler"><a href="javascript: void(0);" id="NextPage"><font color="#EFEFEF">Next Page</font></a> <font color="red">|</font> <a href="javascript: void(0);" id="PreviousPage"><font color="#EFEFEF">Previous Page</font></a> </div> <div class="classcycler2"><a class="downclass" href="javascript: void(0);"><font color="#EFEFEF">Scroll Down</font></a> <font color="red">|</font> <a class="upclass" href="javascript: void(0);"><font color="#EFEFEF">Scroll Up</font></a> </div> <div class="headright"><a class="TOPJS" href="javascript: void(0);"><font color="#EFEFEF">Up to Top</font></a> <br/> <a class="KEYJS" href="javascript: void(0);"><font color="#EFEFEF">Down to Bot</font></a> </div> </div> </div> <div id="container"> <table id="gradient-style" summary=""> <tbody><thead><tr><th colspan="30">Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>>Data>>>>>Test>>>>>123>>>>>Please>>>>>Help>>>>>Stackoverflow>>>>>Testing>>>>>Here>>>>></th></tr></thead></tbody></table> </div> <div id="footer_container"> <div id="footer"> <div class="footimage"> <a href="http://website.com/" target="_blank"> <img alt="" class="footimager" src="http://placehold.it/350x95/" /> </a> </div> <div class="footleft"> <a class="def" href="javascript: void(0);"></a> </div> <div class="footright"> <a class="abc" href="javascript: void(0);"></a> </div> </div> </div> </body> </html> ``` CSS ``` body { background: #F0F0F0; line-height: 1.6em; margin: 0; overflow-x: scroll; padding: 0; } #header_container { background: url(gradhead.png) repeat-x #111625; border: 0 solid #666; height: 80px; left: 0; position: fixed; top: 0; width: 100%; } #footer .headimage { position: relative; } #header .headright { font-size: 20px; position: fixed; right: 10px; text-align: right; top: 15px; } #header .class-selector { left: 10px; position: fixed; top: 5px; } #header .classcycler { font-size: 20px; left: 10px; position: fixed; top: 30px; } #header .classcycler2 { font-size: 20px; left: 10px; position: fixed; top: 50px; } #container { margin: 0 auto; padding: 80px 0; width: 100%; } #footer_container { background: url(gradhead.png) repeat-x #111625; border: 0 solid #666; bottom: 0; height: 80px; left: 0; position: fixed; width: 100%; } #footer .footleft { font-size: 20px; left: 10px; position: absolute; top: 10px; } #footer .footright { font-size: 20px; position: absolute; right: 10px; top: 10px; } #footer .footimage { position: relative; top: -13px; } #footer .footleft a { background: url(http://placehold.it/60x60/) no-repeat; display: block; height: 60px; width: 60px; } #footer .footleft a:hover { background: url(http://placehold.it/60x60/000) no-repeat; } #footer .footright a { background: url(http://placehold.it/60x60/) no-repeat; display: block; height: 60px; width: 60px; } #footer .footright a:hover { background: url(http://placehold.it/60x60/000) no-repeat; } #header,#footer { color: #ECECEC; height: 100%; margin: 0 auto; position: relative; text-align: center; width: 100%; } @media screen and max-width 600px { .headimager { display: none; } } @media screen and max-width 450px { .footimager { display: none; } } ``` The reason there is no jsfiddle link is because it doesn't allow me to put the meta tags in. JavaScript ``` $("a.def").click(function () { $('body').animate({ "scrollLeft": "-=404" }, 200); }); $("a.abc").click(function () { $("body").animate({ "scrollLeft": "+=404" }, 200); }); ```

Original source