pablo
pablo

Reputation: 2809

canvas inside a div with overflow-y

I have a div with overflow-y and inside it a canvas. When I scroll down, I'm getting at the bottom a strip in FF, Chrome and IE9. How can I make this strip go away?

The red strip can be seen here

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<style>
  article, aside, figure, footer, header, hgroup, 
  menu, nav, section { display: block; }

  #container {
    overflow-y: scroll;
    width: 900px;
    height: 400px;
    background-color: red;
  }

  #container canvas {
    background-color: gray;
  }
</style>
<script type="text/javascript">
  var init = function() {
    var container = document.getElementById('container');
    var canvas = document.createElement('canvas');
    canvas.width = container.clientWidth;
    canvas.height = 1000;
    container.appendChild(canvas);
    container.scrollTop = container.scrollHeight;
  }
  </script>
</head>
<body onload="init()">
  <div id="container"></div>
</body>
</html>

Upvotes: 2

Views: 6067

Answers (1)

Mr. Alien
Mr. Alien

Reputation: 157324

Add display: block; in #container canvas:

#container canvas {
    background-color: gray;
    display: block;
}

Demo

Upvotes: 4

Related Questions