1

I'm having an issue with a <div> pushing up another <div> from underneath.

Basically, the <div> above is a <canvas> of defined dimensions, and underneath is a <div> that contains a <p> element. After a event is fired, I'm using innerHTML to change the contents of the <p> element. Because of this, the content of the <p> element goes from one line to two. When that happens, however, the <canvas> is pushed up the page.

I've tried using different position CSS values, but because I'm using flexbox it means that the two divs stack up.

Here's the CSS and HTML:

.container {
  padding: 10px;
  height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.player {
  margin-bottom: 20px;
}

.textContainer {
  font-size: 24px;
  text-align: center;
}
<!DOCTYPE html>
<html>
  <head>
    <link href="style.css" rel="stylesheet" type="text/css">
    <script src="main.js"></script>
  </head>
  <body>
    <div class="container">
      <div class="player">
        <canvas id="canvas"></canvas>
      </div>
      <div class="textContainer">
        <p id="moveText">Moves: 0</p>
      </div>
    </div>
  </body>
</html>

Thanks in advance!

0 Answers0