Scrolling vertically results in scrolling horizontally

As I build a frame and grid for my website, an issue arises whenever the page extends to display the vertical scrollbar, the horizontal one appears as well. I've experimented with various overflow-y settings like auto or hidden, but none of them seem to solve the problem. Could this be related to my use of vw sizes throughout? Here's the Fiddle - http://jsfiddle.net/u11812br/

HTML

<header>
<img src="img/logo_big.png"/>
<button class="menu">
<a href="#menu">&#9776;</a>
</button>

<nav style="display:none;">
    <a href=""><p>HOME / GEDANE ZAKEN</p></a>
    <a href=""><p>CONTACT</p></a>
</nav>

</header>

<div class="spacer"></div>

<center>
<div class="gridcontainer">

<div class="section group">
<div class="col span_2_of_2">
<img src="img/img1.png"/>
</div>
</div>

<div class="section group">
<div class="col span_1_of_2">
<img src="img/img1.png"/>
</div>
<div class="col span_1_of_2">
<img src="img/img1.png"/>
</div>
</div>

<div class="section group">
<div class="col span_2_of_3">
<img src="img/img1.png"/>
</div>
</div>

<div class="section group">
<div class="col span_2_of_3">
<img src="img/img1.png"/>
</div>
</div>

<div class="section group">
<div class="col span_1_of_2">
<img src="img/img1.png"/>
</div>
<div class="col span_1_of_2">
<img src="img/img1.png"/>
</div>
</div>

<div class="section group">
<div class="col span_2_of_2">
<img src="img/img1.png"/>
</div>
</div>

</div>
</center>

CSS

body, html { 
height: 100%; 
margin: 0; 
padding: 0; 
border: none;
left: 0;
top: 0;
width: 100%;
}

body {
background: #f6cb4a; /* Old browsers */
background: -moz-linear-gradient(top, #ebe7e7 0%, #f3f2f2 100%); /* FF3.6+  */
background: -webkit-gradient(linear, left top, left bottom, color-  stop(0%,#ebe7e7), color-stop(100%,#f3f2f2)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ebe7e7 0%,#f3f2f2 100%); /*   Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ebe7e7 0%,#f3f2f2 100%); /* Opera  11.10+ */
background: -ms-linear-gradient(top, #ebe7e7 0%,#f3f2f2 100%); /* IE10+ */
background: linear-gradient(top, #ebe7e7 0%,#f3f2f2 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ebe7e7', endColorstr='#f3f2f2',GradientType=0 ); /* IE6-9 */
height: 100%;
background-repeat: no-repeat;
background-attachment: fixed;
width: 100%;
background-position: 0px 0px;
}

header {
width: 100vw;
height: 65px;
background: white;
position: fixed; 
z-index: 9999;
top: 0px;
}

header img {
width: 85px;
margin-left: 40px;
margin-top: 3px;
}

.spacer {
height: 80px;
width: 100vw;
}

button { 
position: absolute; 
right: 10vw; 
border: none; 
margin: 0; 
padding: 0; 
background: none; 
}

button a { 
font-size: 4em; 
text-decoration: none; 
color: grey; 
}

nav {
position: fixed;
top: 65px;
}

nav p {
width: 100vw;
padding: 25px 0px 25px 0px;
background: white;
margin: 0px;
border-top: 1px solid #ededed;
transition: 0.3s;
}

nav p:hover {
background: #ededed;
}

nav a {
text-align: center;
text-decoration: none;
color: #333;
}

.gridcontainer {
width: 95vw;
}

.section {
clear: both;
padding: 0px;
margin: 0px;
}

.col {
display: block;
float:left;
margin: 1% 0 1% 1.5%;
background: green;
}
.col:first-child { margin-left: 0; }

.group:before,
.group:after { content:""; display:table; }
.group:after { clear:both;}
.group { zoom:1; /* For IE 6/7 */ }
/*  GRID OF TWO  */
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 49.25%;
}

.span_2_of_3 {
width: 49.25%;
}

.span_1_of_2 img {
width: 47vw;
height: 65vw;
display: inline-block;
}

.span_2_of_2 img {
width: 95vw;
height: 60vw;
}


.span_2_of_3 img {
width: 95vw;
height: 30vw;
}


@media only screen and (max-width: 480px) {
.col { 
    margin: 1% 0 1% 0%;
}
}

@media only screen and (max-width: 480px) {
.span_2_of_2, .span_1_of_2 { width: 100%; }
}

Answer №1

When calculating using "vw", the right scrollbar is not taken into account.

One solution is to set a maximum width of approximately "98vw",
or simply add "overflow-x": hidden to prevent horizontal scrolling. Remember, overflow-y controls the vertical axis ;)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Identifying mouse proximity through processing.js

I am using processing.js for coding. I am trying to dynamically adjust the size variable so that it increases as the cursor approaches the ellipse and decreases as the cursor moves away from it. I also want to set a limit for the size, preferably between 5 ...

What is the most effective method for relocating a DIV element across the webpage?

Struggling to find a solution for my problem. I have functions that fetch data from an API and display it in a div when a user right-clicks on a context menu. The div is currently fixed to the bottom right of the page, but I want it to be draggable so user ...

Is it possible to build an AngularJS application without utilizing HTML5?

Having created an AngularJS application, I have noticed that it functions smoothly on modern browsers. However, some of my devices run on old browsers that do not support html5. Unfortunately, I am unable to upgrade these browsers. Is there a method to ope ...

Switching icon images using JQuery based on state changes

I'm attempting to switch the background image of my webpage's "body" element when the user toggles between playing and pausing music icons. This is what the CSS for the "body" element looks like: body { background: url('https://s3-us-wes ...

Aligning the image at the center within a flex container

I am struggling with aligning an image and a link inside a div using the display: flex property. This is how my code looks: <div style="display: flex;"> <div class="site-title-container"> <img style="border-radius: 7px; width: 34px; h ...

Monitoring the content of a page with jQuery and adjusting the size as needed

Here is a code snippet: function adjustContainerHeight() { $('div#mainContainer').css({ 'min-height': $(document).height() - 104 // -104 compensates for a fixed header }).removeShadow().dropShadow({ 'blur&a ...

Redirect the Submit button to the specified URL from the form element

Looking for a way to create a form with two fields: Username and Password. Upon clicking submit, the username and password should be added to the URL in a specific format. For instance: The URL structure will remain the same, only the "username_entered_i ...

Set up two separate tables with sufficient space in between each other

Is there a way to align these two tables next to each other with some space between them? Currently, they appear one below the other. How can I make them sit beside each other with spacing in between? If anyone knows how to do this, please help me out. &l ...

Why is my form not responding to jquery closest function?

In the code snippet below, I am attempting to add form code inside a form. However, because the form ID changes, I am using closest(); to achieve this. $("#contentarea").closest("form").html("some code"); Check out the demo here. ...

What is the best way to create a sign-up box that appears on the same page when you click on the sign-up button

I am interested in implementing a 'sign up' box overlay at the center of my index page for new users who do not have an account. I would like them to be able to easily sign up by clicking on the 'sign up' button. Once they complete the ...

There are three dropdown menus in my form, and the options available in each one are based on the choices made in the

I need to create a form with three dropdown menus. Each menu should display options based on the selection made in the previous one. For example, there should be dropdowns for categories, car brands, and car models. The car brand dropdown should only sh ...

What is the best way to create titles with a background?

My goal is to have a title overlay an image with specific width and the text displayed in blocks. To better illustrate, here's an example: I prefer to achieve this effect using CSS; however, I am open to utilizing Javascript if needed. ...

Angular: Utilizing Nested ng-repeat Alongside groupBy Feature on Initial Page Load or Refresh

With some help, I've made it this far on my project. However, I need to take one more step to achieve my goal. I want to group data based on an attribute that is currently passed through an ng-click action. Is there a way to automatically do this on p ...

The dimensions of the HTML table do not adjust properly when new items are being appended using JavaScript

I utilized this HTML Code to generate a table: <div class="noten_tabelle"> <table id="grades_table" style="width:100%"> <tr> <th>Subject</th> <th>Oral</th&g ...

Retrieve information from each row and extract the input values, as well as the attributes tr.data() and td.data()

Currently, I am exploring the usage of DataTables to see if I can successfully integrate it into my website. Despite searching on DataTables and Stack Overflow forums, as well as conducting Google searches, I have not come across a solution that addresses ...

Attempting to evenly distribute items within a div container

My goal is to arrange the items in the container div evenly on a single line. I want them to be spaced out like this: https://i.sstatic.net/kA2zj.png I'm struggling to achieve this layout where the items are on the same line and evenly distributed w ...

updateStatusCallback function is not defined in the Facebook example using jQuery

I've been trying to incorporate Facebook integration into my HTML code, specifically adding features like Facebook login and sharing functionalities. However, I've hit a roadblock in the process. Even after searching extensively for solutions, I ...

Employing a lexicon of hexadecimal color code values to harmonize CSS styles

I have a unique requirement where I need to utilize a dictionary of HTML color codes and then apply those colors as styles. It's an interesting challenge! Here is an example of how my color dictionary looks like: const colorCodes = { red: ...

Implementing the onEnded event handler for an HTML video element

I recently experimented with the video tag using flowplayer and I wanted to share my code below: <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"> </script> <!-- 2. flowplayer --> <script src="http://releas ...

Discovering visible ID numbers on the screen

My content includes the following: <div id="sContainer"> <div class="message0" id="l0">Initial Content 111</div> <div class="message1" id="l1">Initial Content 222</div> <div class="message2" id="l2">Initial ...