43

I am having an issue with my responsive stylesheet with Twitter Bootstrap. The site shows up fine with no issues but for whatever reason the responsive tablet and phone have this huge white gap to the right of the page. Its not the scroll bar issue its a huge white gap

https://i.stack.imgur.com/AllrQ.png

I dont believe I have changed to much at all here. Nothing with width or anything. Inspected the objects in Chrome and couldnt see anything overflowing over width wise

Lynx
  • 1,462
  • 5
  • 32
  • 59

13 Answers13

76

This might be a little late but I found the other answers to be misleading.

It is true that the row class is what is causing the issue, but that is because it is always supposed to be placed inside a container element.

from http://getbootstrap.com/css/ :

Rows must be placed within a .container (fixed-width) or .container-fluid (full-width) for proper alignment and padding.

The container element usually has a -15px padding on both right and left and the row class has a 15px padding on right and left. The two cancel each other out. If one of the two is not present you will see extra space.

Nicola Pedretti
  • 4,831
  • 3
  • 36
  • 42
  • 8
    `row`s on my page are within `container` or `container-fluid` but I still see the big white space on the right. Cant figure it out even with Chrome dev tools. This happens only on pages with forms. Any ideas? – Anupam Mar 20 '18 at 09:23
52

Have you tried:

html, body { overflow-x: hidden; }

Can you post a fiddle?

Giulio
  • 783
  • 7
  • 21
10

Add the following meta tag to your HTML

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=320, height=device-height, target-densitydpi=medium-dpi" />

Also try setting

html, body. div{
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
}

on the html and body

Scott Selby
  • 9,420
  • 12
  • 57
  • 96
  • 1
    didnt work...If it helps narrowing it down..It looks like its only about 20-30px gap on tablets(ipad) and about a 50-60px gap on smartphones(vivid) – Lynx May 23 '13 at 02:58
  • don't know , without any html or css code posted , those were the best probably fixes , couldn't really tell you much more – Scott Selby May 23 '13 at 03:19
  • Yeah i understand I wish I could post code but cannot. I guess i can figure it out lol thanks again! – Lynx May 23 '13 at 03:25
  • What if I want it w/o margin therefore use container-fluid? – haneulkim Jul 29 '19 at 17:01
  • flashback to the past, 2019 thanking 2013 for this meta tag help haha – caro Oct 18 '19 at 22:34
  • The white bar error was taking over my page when I shrunk its width, changing the meta fixed it. – Naman Bansal Aug 10 '20 at 10:26
7

I am having the same problem. I discovered the object that was causing the padding to be created was Bootstrap's "row" class.

If you add

.row {
  padding-right: 0px;
  margin-right: 0px;
}

to your CSS file/row objects this should fix at least one of items causing padding on your page.

Jacob
  • 113
  • 1
  • 2
  • 4
    The row padding is intentional. You should be wrapping your rows in a `.container-fluid`. – Andrew May 28 '16 at 00:39
5

I had this problem, no one of this answers, did not help me, i solved my problem with this way:

body { overflow-x: hidden; width: 100vw;}
Abolfazl Miadian
  • 3,099
  • 2
  • 19
  • 15
1

Generally this happens because you have a div breaking the boundaries of your set container width,could be a div or sections padding, margin, positioning.. you can use the inspector arrow or overflow:hidden on the container tag to see what section you might have breaking the width.

1

I had a very similar issue recently which took me quite sometime to figure out. For me, it was not the usual row/container issue. I was using a form-control to render checkboxes manually. In Bootstrap, all textual elements with form-control have width:100% by default. Having many checkboxes online was causing them to spill over (invisibly) and causing this large white gap on the right. Surprisingly, it wasn't easy to debug this using Chrome Dev tools either.

I am now using the following solution to set the width to auto; (this answer helped):

<input class="form-control form-control-inline" type="checkbox" ... ... .. />

and

.form-control-inline {
  width: auto;
}

Hope it helps someone

Anupam
  • 14,950
  • 19
  • 67
  • 94
1

My answer is an extension to @scott Shelby's answer.

I was able to get rid of the annoying white bar in the right by changing the meta of my file:

<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=320, height=device-height, target-densitydpi=medium-dpi" />

Even after changing the meta, I was getting the white bar on my table as it was overflowing in mobile devices.

To fix this, I made sure to make all elements like images, forms, etc. responsive.

For images, you can use class: "img-fluid"

and for tables, you can use class: table-responsive in the parent div.

Naman Bansal
  • 191
  • 2
  • 13
0

Also, check to see how you're using containers. They can't be nested, they will cause problems.

You may choose one of two containers to use in your projects. Note that, due to padding and more, neither container is nestable.

Source: http://getbootstrap.com/css/#overview-container

vikvan
  • 11
  • 1
0

I just had a very similar problem, and after spending some time, I realized I had applied CSS styling adding padding of 0px on both left and right of a container-fluid class, and therefore the styling overrode the default -15px padding needed on container-fluid to hold rows in their proper place.

Eddie Teixeira
  • 332
  • 2
  • 13
0

I've had a similar issue on mobile devices. The problem was that I had hidden an element on smaller screen sizes, but forgot its parent container. This container was still being rendered even though its content was empty, which lead to a big white gap on the right site. Hiding the parent element instead of the child solved this for me.

AverageJoe
  • 21
  • 1
  • 5
0

I also have this issue with a gap on one side. After long time I found out I didn't follow the Bootstrap structure. You have to be careful. row cannot contain a container; this will also cause a gap issue. So: container cannot be nested. row cannot nest a container. row has to be in a container.

How
  • 26
  • 3
0
/* Hide horizontal scrollbar */
.body, .head, .row, .col {
  overflow-x: hidden;
}

Doing this allows you to have a sticky navbar but still get rid of the whitespace!

Taylor D
  • 542
  • 5
  • 10