NeuroAgent

White Vertical Bar on Right Side in Fullscreen Mode: Causes and Solutions

Discover why a white vertical bar appears on the right side in fullscreen mode and learn how to fix it using CSS and JavaScript solutions.

Question

Why does a white vertical stripe appear on the right side when viewing the website in fullscreen mode?

I built a website for a web programming lab assignment (not responsive design). When viewing the website in fullscreen mode, a white vertical stripe appears on the right side. In developer tools at 1440px resolution, everything displays correctly. With Perfect Pixel extension, both in developer tools and fullscreen mode, everything aligns properly, but I’m concerned about the white stripe on the right in fullscreen mode. I tried removing pages of the website one by one through developer tools to determine which page has the problem, but found nothing.

NeuroAgent

A white vertical bar on the right in fullscreen mode most often occurs due to a horizontal scrollbar or a mismatch between the container width and screen width. This is a common problem, especially in non-responsive designs where the content has a fixed width different from the screen resolution.

Table of Contents

Main causes of white bar appearance

A white vertical bar on the right in fullscreen mode can appear for several main reasons:

  1. Horizontal scrollbar - the most common cause. When the total width of content exceeds the screen width, the browser automatically adds a horizontal scrollbar that creates a visual white bar.

  2. Container width mismatch - your website’s fixed width may not match the screen resolution in fullscreen mode, causing empty space to appear.

  3. Padding and margins - unnoticed padding or margins in CSS can accumulate and create additional space.

  4. Background images - if a background image doesn’t stretch to full width, it may be cut off, creating a white bar.

As noted on Stack Overflow, a horizontal scrollbar appears when “the page exceeds the browser’s innerHeight”.


Checking for horizontal scroll

The first task is to check if a horizontal scrollbar appears:

  1. Open the website in fullscreen mode
  2. Check if there’s a horizontal scrollbar at the bottom of the screen
  3. If it exists, that’s the cause of the white bar on the right

According to research from W3Schools, a horizontal scrollbar appears when content exceeds the available screen width.

To temporarily test this hypothesis, add to your CSS:

css
html {
  overflow-x: hidden;
}

If the bar disappears, the problem is indeed the horizontal scrollbar.


CSS solutions

1. Removing horizontal scrollbar

The simplest way is to hide the horizontal scrollbar:

css
html, body {
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

As explained on W3Schools, overflow: hidden hides both scrollbars.

2. Adjusting container width

If you have a container with fixed width, check its settings:

css
.main-container {
  width: 100vw; /* Instead of fixed width */
  max-width: 100vw;
  box-sizing: border-box;
}

It’s important to use box-sizing: border-box so that padding doesn’t increase the total width.

3. Using negative margins for full-width elements

For elements that should stretch to full width, as recommended on CSS-Tricks:

css
.full-width-section {
  position: relative;
  margin: 0 -30px; /* Negative margin */
  padding: 0 30px; /* Compensating padding */
}

4. Checking hidden elements

Sometimes the problem lies in hidden elements. As mentioned on Stack Overflow, even hidden elements like <input type="submit"> can cause margin issues.


JavaScript for fullscreen mode management

For more precise fullscreen mode control, you can use JavaScript:

javascript
function toggleFullscreen(elem) {
  elem = elem || document.documentElement;
  
  if (!document.fullscreenElement && 
      !document.mozFullScreenElement && 
      !document.webkitFullscreenElement && 
      !document.msFullscreenElement) {
    
    if (elem.requestFullscreen) {
      elem.requestFullscreen();
    } else if (elem.msRequestFullscreen) {
      elem.msRequestFullscreen();
    } else if (elem.mozRequestFullScreen) {
      elem.mozRequestFullScreen();
    } else if (elem.webkitRequestFullscreen) {
      elem.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
    }
  } else {
    if (document.exitFullscreen) {
      document.exitFullscreen();
    } else if (document.msExitFullscreen) {
      document.msExitFullscreen();
    } else if (document.mozCancelFullScreen) {
      document.mozCancelFullScreen();
    } else if (document.webkitExitFullscreen) {
      document.webkitExitFullscreen();
    }
  }
}

// Handler for hiding scrollbar in fullscreen mode
document.addEventListener('fullscreenchange', function() {
  if (document.fullscreenElement) {
    document.body.style.overflow = 'hidden';
  } else {
    document.body.style.overflow = '';
  }
});

This code, as shown in the example, allows you to control the scroll state when entering and exiting fullscreen mode.


Diagnostic tools

Since Perfect Pixel shows correct display while real fullscreen doesn’t, it’s worth using additional diagnostic tools:

  1. Chrome Element Inspector - press F12 and check:

    • The total page width
    • Presence of horizontal scrollbar
    • Margins and sizes of all containers
  2. Device Mode - in Chrome DevTools, you can simulate various mobile devices and check behavior.

  3. Measurement extensions - use extensions like “What’s My Screen Resolution” for precise measurement.

As developers mention on Stack Overflow, sometimes the issue lies in specific browser behavior in fullscreen mode.


Practical code examples

Complete solution for fixed design

css
/* Basic settings to prevent scrollbars */
html, body {
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  width: 100%;
}

/* Main container */
.main-container {
  width: 1440px; /* Your fixed width */
  margin: 0 auto;
  position: relative;
}

/* Background elements for full coverage */
.full-width-bg {
  position: absolute;
  left: -50px;
  right: -50px;
  width: calc(100% + 100px);
  z-index: -1;
}

/* For fullscreen elements */
.fullscreen-section {
  width: 100vw;
  position: relative;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

JavaScript for fullscreen mode adaptation

javascript
// Check and adjust on window resize
window.addEventListener('resize', function() {
  if (window.innerWidth === screen.width && 
      window.innerHeight === screen.height) {
    // Fullscreen mode
    document.body.style.overflow = 'hidden';
    document.body.style.width = '100vw';
    document.body.style.height = '100vh';
  } else {
    // Normal mode
    document.body.style.overflow = '';
    document.body.style.width = '';
    document.body.style.height = '';
  }
});

As shown in examples on DEV Community, it’s important to properly set height and width values to prevent unwanted scrollbars from appearing.

Sources

  1. Stack Overflow - White space showing up on right side of page
  2. CSS-Tricks - Full Browser Width Bars
  3. W3Schools - How To Hide Scrollbars With CSS
  4. Stack Overflow - Fullscreen website shows horizontal scrollbar
  5. Stack Overflow - White bottom & top bars on full screen in Chrome
  6. DEV Community - How to set and customize scrollbars with CSS
  7. Stack Overflow - Remove vertical scrollbar on fullscreen

Conclusion

A white vertical bar on the right in fullscreen mode is a typical problem caused by one of the following issues:

  1. Horizontal scrollbar - the most common cause, solved by adding overflow-x: hidden
  2. Width mismatch - check container sizes and use 100vw for full coverage
  3. Padding and margins - ensure accumulated padding doesn’t create extra space
  4. Hidden elements - check for hidden elements that might affect the layout

For your lab work, I recommend starting with checking for horizontal scrollbar by temporarily adding overflow-x: hidden. If this solves the problem, then you can find the specific element causing the scrollbar and adjust its sizes correctly.

Also note that Perfect Pixel works differently than actual fullscreen mode, so trust testing in real browser conditions.