0

I am in a bit of a pickle trying to vertically align a div. What I aim to achieve is to have 3 divs with height: 100% and width:33% to have a centered content div. Can anyone help? Here is the code:

.wrapper {
  height: 100%;
  width: 100%;
}
.window {
  width: 33%;
  float: left;
  background-color: #666;
}
.windowContent {
  background-color: #000;
}
<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>

<body>
  <div class="wrapper">
    <div class="window">
      <div class="windowContent">
      </div>
    </div>

    <div class="window">
      <div class="windowContent">
      </div>
    </div>

    <div class="window">
      <div class="windowContent">
      </div>
    </div>

  </div>

</body>

</html>
Mandarr Sant
  • 595
  • 6
  • 20
  • 1
    [Vertical alignment of elements in a div](http://stackoverflow.com/a/84616/4071864) – Rens Jan 25 '17 at 13:28
  • 1
    Possible duplicate of [Vertical alignment of elements in a div](http://stackoverflow.com/questions/79461/vertical-alignment-of-elements-in-a-div) – skAstro Jan 25 '17 at 13:30
  • The problem is that I want 100% height, not a set value –  Jan 25 '17 at 13:30

1 Answers1

1

Try this example

<div class="wrapper">
    <div class="window">
        <div class="windowContent">
        1
        </div>
    </div>

    <div class="window">
        <div class="windowContent">
        2
        </div>
    </div>

<div class="window">
        <div class="windowContent">
        3
        </div>
    </div>

</div>

CSS

.wrapper
    {
      height: 100%;
      width: 100%;
      display: flex;
    }

    .window
    {
      width: 100%;
      min-height: 200px;
      background-color: #666;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .windowContent
    {
      background-color: #000;
      color: #fff;
    }

Demo - https://jsfiddle.net/xa3v1c3o/

grinmax
  • 1,719
  • 1
  • 8
  • 13