mseifert
mseifert

Reputation: 5670

Container width not matching viewport width on mobile device

I recoded my site for responsive design and set the HTML viewport, javascript, and CSS for the outer container div as shown below. On mobile browsers (Opera and Firefox) I have the following problem:

Setting overflow-x prevents scrolling to the right but this seems dangerous (If there is data to the right for whatever reason, you want to be able to get to it).

Notes:

Any idea why this space to the right and how to get rid of it?

HTML

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

CSS (relevant)

.page-container {
    position: relative;
    width: 100%;
    min-width:240px;
}

JS

var jmq = window.matchMedia("screen and (max-width: 610px)");
jmq.addListener(jmqListener);

function jmqListener(jmq){
    if (jmq.matches || window.innerWidth < 611 ) {
        //Mobile or zoomed in desktop - resize controls
        ...
    } else {
        // full desktop site
        ...
    }

A picture is worth a thousand words - the extra space is on the right:

screenshot

Upvotes: 2

Views: 1817

Answers (1)

Jared
Jared

Reputation: 12524

You have fixed widths on some of the elements in your header.

.sitemessage h2 has a fixed width of 470px

.sitename has a fixed width of 475px

Setting those widths to auto will correct the issue.

Upvotes: 2

Related Questions