Scrolling overlay leaving an extra scroll bar behind

I am using a vertically scrollable overlay - based on http://tympanus.net/Development/FullscreenOverlayStyles/index7.html with a few tweaks to make it scrollable (as it’s longer than the average viewport).

It’s almost working fine. Only problem is, after the overlay has been closed it leaves behind an extra vertical scrollbar. It is to the left of the real scroll and has no ‘grabbable’ bar within it.

div.overlay-inside is a wrapper inside the main div.overlay

Initial css is

.overlay {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background: rgba(153,204,51,0.9);
	z-index: 100;
	overflow-y:scroll;
}
.overlay-inside {
        position: static;
}

javascript is

 $('.trigger-overlay').click(function() {
  $('.overlay').css('overflow-y', 'scroll');
  $('body').css('overflow-y', 'hidden');
  $('body').css('position', 'fixed');
  $('body').css('height', '100%');
  $('body').bind('touchmove', function(e) {
     e.preventDefault()
  });
  $('.overlay').on('touchmove touchstart', function (e) {
       e.stopPropagation();
   });	 
 });
 $('.overlay-close').click(function() {
  $('.overlay').css('overflow-y', 'hidden');
  $('body').css('overflow-y', 'scroll');
  $('body').css('position', 'static');
  $('body').css('height', 'auto');
  $('body').unbind('touchmove');
 });

Have tried all sorts of things, but can’t get rid of it! Any pointers appreciated.

Hi,

You will need to set up a working demo as I can’t get your code to work as you explained.

Here’s the nearest working demo but it doesn’t seem to show your problem.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html, body {
	margin:0;
	padding:0;
	height:100%
}
.overlay {
	position:fixed;
	display:none;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background: rgba(153,204,51,0.9);
	z-index: 100;
	overflow-y:scroll;
}
.overlay-inside {
	position: static;
}
</style>
</head>

<body>
<button class="trigger-overlay">Click to open</button>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<div class="overlay">
  <div class="overlay-inside">
    <button class="overlay-close">Close</button>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
    <p>content</p>
  </div>
</div>
<script
      src="https://code.jquery.com/jquery-2.2.4.min.js"
      integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
      crossorigin="anonymous"></script> 
<script>
 $('.trigger-overlay').click(function() {
  $('.overlay').css('overflow-y', 'scroll');
  $('.overlay').css('display', 'block');
  $('body').css('overflow-y', 'hidden');
  $('body').css('position', 'fixed');
  $('body').css('height', '100%');
  $('body').bind('touchmove', function(e) {
     e.preventDefault()
  });
  $('.overlay').on('touchmove touchstart', function (e) {
       e.stopPropagation();
   });	 
 });
 $('.overlay-close').click(function() {
  $('.overlay').css('overflow-y', 'hidden');
  $('.overlay').css('display', 'none');
  $('body').css('overflow-y', 'auto');
  $('body').css('position', 'static');
  $('body').css('height', 'auto');
  $('body').unbind('touchmove');
 });
</script>
</body>
</html>

I’m not sure why you are setting the body to position:fixed exactly and the css rules in the js would have been easier as a swapped css class instead.

Thanks Paul. Stripped down version is

<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="Description" lang="en" content=".">

<style>
/* Overlay style */
.overlay {
	position: fixed;
	width: 100%;
	height: 100%;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background: rgba(153,204,51,0.9);
	z-index: 100;
	overflow-y:scroll;
}
.overlay-inside {
position: static;
}
/* Overlay closing cross */
.overlay .overlay-close {

	position: absolute;
	right: 20px;
	top: 20px;

}

html, body {
	overflow-x: hidden;
}

/* Menu style */
.overlay nav {
	text-align: center;
	position: relative;
	top: 50%;
	height: 60%;
	-webkit-transform: translateY(-50%);
	transform: translateY(-50%);
}

.overlay ul {
	list-style: none;
	padding: 0;
	margin: 0 auto;
	display: inline-block;
	height: 100%;
	position: relative;
}

.overlay ul li {
	display: block;
	height: 20%;
	height: calc(100% / 5);
	min-height: 54px;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.overlay ul li a {
	font-size: 54px;
	font-weight: 300;
	display: block;
	color: #fff;
	-webkit-transition: color 0.2s;
	transition: color 0.2s;
}

.overlay ul li a:hover,
.overlay ul li a:focus {
	color: #f0f0f0;
}

/* Effects */
html, body {
	overflow-x: hidden;
}

#MainSection {
	overflow-x: hidden;
	-webkit-transition: -webkit-transform 0.5s;
	transition: transform 0.5s;	
}

#MainSection.overlay-open {
	-webkit-transform: translateX(50%);
	transform: translateX(50%);
}

#MainSection::after {
	content: '';
	opacity: 0;
	visibility: hidden;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.6);
	-webkit-transition: opacity 0.5s, visibility 0s 0.5s;
	transition: opacity 0.5s, visibility 0s 0.5s;
}

#MainSection.overlay-open::after {
	visibility: visible;
	opacity: 1;
	-webkit-transition: opacity 0.5s;
	transition: opacity 0.5s;
}

.overlay-contentpush {
	background: rgba(153,204,51,1);
	visibility: hidden;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	-webkit-transform: translateX(-100%);
	transform: translateX(-100%);
	-webkit-transition: -webkit-transform 0.5s, visibility 0s 0.5s;
	transition: transform 0.5s, visibility 0s 0.5s;
}

.overlay-contentpush.open {
	visibility: visible;
	-webkit-transform: translateX(0%);
	transform: translateX(0%);
	-webkit-transition: -webkit-transform 0.5s;
	transition: transform 0.5s;
}


</style>
</head>

<body>

	<div id = 'MainSection'>

<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
		<a  href = '#' class = "trigger-overlay ">Open form</a>	
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />

 </div>

	<!-- overlay -->
	<div class="overlay overlay-contentpush">
		<div class = "overlay-inside">
		<button type="button" class="overlay-close">Close</button>
		<div class = 'row'>
			<div id="contact_form"  class = 'container-wide'>
			<form name="contact" action="">
				<ul>
					<li>
					<label for="name" id="name_label">Name</label>
					<input type="text" name="name" id="name" size="30" value="" class="text-input"  required />
					<label class="error" for="name" id="name_error">This field is required.</label>
					</li>
					<li>
					
					<label for="email" id="email_label">Email</label>
					<input type="email" name="email" id="email" size="30" value="" class="text-input" />
					<label class="error" for="email" id="email_error">This field is required.</label>
					</li>
					<li>
					<label for="phone" id="phone_label">Phone</label>
					<input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
					<label class="error" for="phone" id="phone_error">This field is required.</label>
					</li>
					<li>
				</ul>
					
					<input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
			</form>
		<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
			</div>
		</div>
		</div>
	</div> <!--overlay-->

	<script src="//code.jquery.com/jquery-2.1.4.min.js"></script>
	<script src="assets/js/classie.js"></script>	
	<script src="assets/js/modernizr.custom.js"></script>	
	<script>
	(function() {
	var container = document.querySelector( '#MainSection' ),
		//change this to work by class..
		//triggerBttn = document.getElementById( 'trigger-overlay' ),
		triggerBttn = document.getElementsByClassName( 'trigger-overlay' ),
		overlay = document.querySelector( 'div.overlay' ),
		closeBttn = overlay.querySelector( 'button.overlay-close' );
		transEndEventNames = {
			'WebkitTransition': 'webkitTransitionEnd',
			'MozTransition': 'transitionend',
			'OTransition': 'oTransitionEnd',
			'msTransition': 'MSTransitionEnd',
			'transition': 'transitionend'
		},
		transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
		support = { transitions : Modernizr.csstransitions };

	function toggleOverlay() {
		if( classie.has( overlay, 'open' ) ) {
			classie.remove( overlay, 'open' );
			classie.remove( container, 'overlay-open' );
			classie.add( overlay, 'close' );
			var onEndTransitionFn = function( ev ) {
				if( support.transitions ) {
					if( ev.propertyName !== 'visibility' ) return;
					this.removeEventListener( transEndEventName, onEndTransitionFn );
				}
				classie.remove( overlay, 'close' );
			};
			if( support.transitions ) {
				overlay.addEventListener( transEndEventName, onEndTransitionFn );
			}
			else {
				onEndTransitionFn();
			}
		}
		else if( !classie.has( overlay, 'close' ) ) {
			classie.add( overlay, 'open' );
			classie.add( container, 'overlay-open' );
		}
	}
	//change this to work by class..
	//triggerBttn.addEventListener( 'click', toggleOverlay );
 for (x=0;x<triggerBttn.length;x++) {
   triggerBttn[x].addEventListener( 'click', toggleOverlay );
  }
	closeBttn.addEventListener( 'click', toggleOverlay );
})();
</script>
	<script>
	  $('.trigger-overlay').click(function() {
			$('.overlay').css('overflow-y', 'scroll');
			$('body').css('overflow-y', 'hidden');
			$('body').css('position', 'fixed');
			$('body').css('height', '100%');
			$('body').bind('touchmove', function(e) {
				e.preventDefault()
			});
			$('.overlay').on('touchmove touchstart', function (e) {
				e.stopPropagation();
			});
		});
		$('.overlay-close').click(function() {
			$('.overlay').css('overflow-y', 'hidden');
			$('body').css('overflow-y', 'scroll');
			$('body').css('position', 'static');
			$('body').css('height', 'auto');
			$('body').unbind('touchmove');
		});
</script>	

</body>
</html>


First chunk of javascript is direct from the demo I’m copying. Second chunk is my attempt at making it scrollable.
Reason for position:fixed on the body, that was the only way I could get the main scroll bar to disappear when overlay opens - would rather not use it as it resets focus back to top of page.
And reason for not using a class was simply I was experimenting with all sorts of things and js seemed the easiest way to do it! I’ll replace it with a class when it’s sorted.
Thanks

You seem to be adding scrollbars to both the body and html elements which is confusing things. You also need to negate the margin/padding on the root elements.

I would do it more simply like this.

<!doctype html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="Description" lang="en" content=".">

<style>
html,body{margin:0;padding:0}
/* Overlay style */
.overlay {
	position: fixed;
	top: 0;
	left: 0;
	bottom: 0;
	right: 0;
	background: rgba(153,204,51,0.9);
	z-index: 100;
	overflow-y:scroll;
}
/* Overlay closing cross */
.overlay .overlay-close {
	position: absolute;
	right: 20px;
	top: 20px;
}

/*never a good idea
html , body {
	overflow-x: hidden;
}
*/

/* Menu style */
.overlay nav {
	text-align: center;
	position: relative;
	top: 50%;
	height: 60%;
	-webkit-transform: translateY(-50%);
	transform: translateY(-50%);
}

.overlay ul {
	list-style: none;
	padding: 0;
	margin: 0 auto;
	display: inline-block;
	height: 100%;
	position: relative;
}

.overlay ul li {
	display: block;
	height: 20%;
	height: calc(100% / 5);
	min-height: 54px;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
}

.overlay ul li a {
	font-size: 54px;
	font-weight: 300;
	display: block;
	color: #fff;
	-webkit-transition: color 0.2s;
	transition: color 0.2s;
}

.overlay ul li a:hover,
.overlay ul li a:focus {
	color: #f0f0f0;
}

/* Effects
html, body {
	overflow-x: hidden;
}
 */
#MainSection {
	overflow-x: hidden;
	-webkit-transition: -webkit-transform 0.5s;
	transition: transform 0.5s;	
}

#MainSection.overlay-open {
	-webkit-transform: translateX(50%);
	transform: translateX(50%);
}

#MainSection::after {
	content: '';
	opacity: 0;
	visibility: hidden;
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0,0,0,0.6);
	-webkit-transition: opacity 0.5s, visibility 0s 0.5s;
	transition: opacity 0.5s, visibility 0s 0.5s;
}

#MainSection.overlay-open::after {
	visibility: visible;
	opacity: 1;
	-webkit-transition: opacity 0.5s;
	transition: opacity 0.5s;
}

.overlay-contentpush {
	background: rgba(153,204,51,1);
	visibility: hidden;
	-webkit-backface-visibility: hidden;
	backface-visibility: hidden;
	-webkit-transform: translateX(-100%);
	transform: translateX(-100%);
	-webkit-transition: -webkit-transform 0.5s, visibility 0s 0.5s;
	transition: transform 0.5s, visibility 0s 0.5s;
}

.overlay-contentpush.open {
	visibility: visible;
	-webkit-transform: translateX(0%);
	transform: translateX(0%);
	-webkit-transition: -webkit-transform 0.5s;
	transition: transform 0.5s;
}


</style>
</head>

<body>

	<div id = 'MainSection'>

<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
		<a  href='#nogo' class="trigger-overlay ">Open form</a>	
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />

 </div>

	<!-- overlay -->
	<div class="overlay overlay-contentpush">
		<div class = "overlay-inside">
		<button type="button" class="overlay-close">Close</button>
		<div class = 'row'>
			<div id="contact_form"  class = 'container-wide'>
			<form name="contact" action="">
				<ul>
					<li>
					<label for="name" id="name_label">Name</label>
					<input type="text" name="name" id="name" size="30" value="" class="text-input"  required />
					<label class="error" for="name" id="name_error">This field is required.</label>
					</li>
					<li>
					
					<label for="email" id="email_label">Email</label>
					<input type="email" name="email" id="email" size="30" value="" class="text-input" />
					<label class="error" for="email" id="email_error">This field is required.</label>
					</li>
					<li>
					<label for="phone" id="phone_label">Phone</label>
					<input type="text" name="phone" id="phone" size="30" value="" class="text-input" />
					<label class="error" for="phone" id="phone_error">This field is required.</label>
					</li>
					<li>
				</ul>
					
					<input type="submit" name="submit" class="button" id="submit_btn" value="Send" />
			</form>
		<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />
			</div>
		</div>
		</div>
	</div> <!--overlay-->

	<script src="http://code.jquery.com/jquery-2.1.4.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/classie/1.0.1/classie.js"></script>	
	<script src="
https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.js"></script>	
	<script>
	(function() {
	var container = document.querySelector( '#MainSection' ),
		//change this to work by class..
		//triggerBttn = document.getElementById( 'trigger-overlay' ),
		triggerBttn = document.getElementsByClassName( 'trigger-overlay' ),
		overlay = document.querySelector( 'div.overlay' ),
		closeBttn = overlay.querySelector( 'button.overlay-close' );
		transEndEventNames = {
			'WebkitTransition': 'webkitTransitionEnd',
			'MozTransition': 'transitionend',
			'OTransition': 'oTransitionEnd',
			'msTransition': 'MSTransitionEnd',
			'transition': 'transitionend'
		},
		transEndEventName = transEndEventNames[ Modernizr.prefixed( 'transition' ) ],
		support = { transitions : Modernizr.csstransitions };

	function toggleOverlay() {
		if( classie.has( overlay, 'open' ) ) {
			classie.remove( overlay, 'open' );
			classie.remove( container, 'overlay-open' );
			classie.add( overlay, 'close' );
			var onEndTransitionFn = function( ev ) {
				if( support.transitions ) {
					if( ev.propertyName !== 'visibility' ) return;
					this.removeEventListener( transEndEventName, onEndTransitionFn );
				}
				classie.remove( overlay, 'close' );
			};
			if( support.transitions ) {
				overlay.addEventListener( transEndEventName, onEndTransitionFn );
			}
			else {
				onEndTransitionFn();
			}
		}
		else if( !classie.has( overlay, 'close' ) ) {
			classie.add( overlay, 'open' );
			classie.add( container, 'overlay-open' );
		}
	}
	//change this to work by class..
	//triggerBttn.addEventListener( 'click', toggleOverlay );
 for (x=0;x<triggerBttn.length;x++) {
   triggerBttn[x].addEventListener( 'click', toggleOverlay );
  }
	closeBttn.addEventListener( 'click', toggleOverlay );
})();
</script>
	<script>
	  $('.trigger-overlay').click(function() {
			$('body').css('overflow', 'hidden');
			$('body').bind('touchmove', function(e) {
				e.preventDefault()
			});
			$('.overlay').on('touchmove touchstart', function (e) {
				e.stopPropagation();
			});
		});
		$('.overlay-close').click(function() {
			$('body').css('overflow', 'auto');
			$('body').unbind('touchmove');
		});
</script>	

</body>
</html>

The above is a working demo so just copy and paste to test.

Of course I don’t know what else was going on but the overlay should be straight forward. No need to mess about with position:fixed on the body just hide the scrollbar on the body when the overlay is open.

The page was jumping to the top because you use an anchor to trigger the overlay and used # as the destination which makes the page jump to the top. Either return false in the js or just set a non existent fragment identifier and it won’t go anywhere.

e.g.

<a href='#nogo' class="trigger-overlay ">Open form</a>

Or use a button instead of a link.

Thank you Paul, works a treat.

Of the changes you advised, it seems it was the removal of the
overflow-x:hidden on body,html (twice!)
that stopped the extra scroll bar
I don’t really understand why? or why I needed to negate margin/padding on root elements? - that doesn’t seem to make any difference
and I don’t really know why you say I was adding a scrollbar to the html element - where was that happening?

I can see there were a lot of unnecessary things going on in the script - I read a lot of stuff and threw everything at it in desparation!
The anchor on the trigger was a real id in my original page, and even with a #nogo, by changing body to fixed and back again, the focus does go back to top of page - but not a problem now I don’t need that!
Again, thanks for your help.

I meant you were hiding the overflow-x scroll bar on the html and the body element and that made no sense because you only needed to hide it on the body so leave html alone. When you start messing with scrolbars on the html and also the body elements you can end up with weird results.:slight_smile:

That was pre-cautionary because you set body to height:100% in your js and height:100% doesn’t work on the body unless you also set html to height:100% and if you do that then the default margin/padding makes the 100% too tall.

e.g. See what happens when you run this:

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html{background:blue;}
body{height:100%;background:red}
</style>
</head>

<body>
</body>
</html>

What colour do you expect the background of the viewport to be?

It will be blue because the height:100% on the body cannot be resolved and becomes height auto which for no content becomes zero height and thus no red will show.

To get the height:100% on body to work you need to add height:100% to the html element as well.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html{background:blue;height:100%}
body{height:100%;background:red}

</style>
</head>

<body>
</body>
</html>

Now the background is red. However there are scroll bars on the viewport from the default margin/padding on the html element. If we remove the padding/margin then everything fits.

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html,body{margin:0;padding:0}
html{background:blue;height:100%;}
body{height:100%;background:red}

</style>
</head>

<body>
</body>
</html>

For historic reasons we negate on both html and body because some browsers applied margin and some applied padding and some applied to html and some applied to body. These days most browsers are standardised but old habits die hard.

As you see the html element is complicated and indeed there are still problems with the above. If you add enough content to scroll then once beyond the bottom of the viewport the background turns back to blue again because the body finished at 100% only.


<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
html, body {
	margin:0;
	padding:0
}
html {
	background:blue;
	height:100%;
}
body {
	height:100%;
	background:red
}
</style>
</head>

<body>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
<p>test</p>
</body>
</html>

The solution is to remove the blue background from the html element because by default a background applied to the body element is automatically propagated to the html element and will cover the canvas automatically. That’s why its best t leave the html alone except for negating padding, margins and setting height when needed. As always the devil is in the detail.

These days of course we can use vh units and avoid some of the above problems.

If you have a real id then no you won’t need it for the new version.:slight_smile:

2 Likes

Makes perfect sense now.
Thanks for your time, and for explaining it so well.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.