<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.css">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js"></script>
<div class="container">
<h1 class="text-center">Remove Scrollbar "Jumping"</h1>
<p class="lead text-center">When centering a page with CSS like <code>margin:auto;</code>, there's a small gotcha: the page will "jump" a little on certain browsers when navigating between short and long pages. This is because the scrollbar gets hidden with short pages and is shown again with longer pages, which makes the page move a little horizontally.</p>
</div>
CSS
@import url(http://fonts.googleapis.com/css?family=Dosis);
html {
/* THE TRICK */
margin-left: calc(100vw - 100%);
overflow: auto;
}
body {
padding: 10px 50px;
font-family: "Dosis", sans-serif;
background: #f0f0f0;
color: #555555;
}
JavaScript
// Bootstrap v3.3.1
// Font Awesome 4.2.0
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.