0

I try do center the div dice-wrapper and Button Horizontaly and Verticaly.The Problem is that if i give the dice-wrapper 100% height, is works fine with the dices, but the button is now at the bottom of the page. When i Put the Button div inside the dice div, the button is on the right site and i cant get in under die dices.

    html,
    body {
      height: 100%;
    }
    
    .container {
      height: 100%;
    }
    
    #dice-wrapper {
      display: flex;
      justify-content: center;
      align-items: center;
      height: auto;
      border: cornflowerblue solid 1px;
    }
    
    .die img {
      max-width: 7rem;
    }
    
    .btn {
      display: flex;
      border: cornflowerblue solid 1px;
    }
     <body>
        <div class="container">
          <div id="dice-wrapper">
            <div class="die">
              <input type="checkbox" id="dice-1" name="dice-1" value="dice-1" />
              <img src="img/dice-5.png" alt="Dice" class="dice1" id="dice-1" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-2" name="dice-2" value="dice-2" />
              <img src="img/dice-5.png" alt="Dice" class="dice2" id="dice-2" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-3" name="dice-3" value="dice-3" />
              <img src="img/dice-5.png" alt="Dice" class="dice3" id="dice-3" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-4" name="dice-4" value="dice-4" />
              <img src="img/dice-5.png" alt="Dice" class="dice4" id="dice-4" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-5" name="dice-5" value="dice-5" />
              <img src="img/dice-5.png" alt="Dice" class="dice5" id="dice-5" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-6" name="dice-6" value="dice-6" />
              <img src="img/dice-5.png" alt="Dice" class="dice6" id="dice-6" />
            </div>
          </div>
          <div class="btn">
            <button class="btn_roll">roll</button>
          </div>
        </div>
        <script type="text/javascript" src="js/app.js"></script>
      </body>
    
  
patmat
  • 23
  • 3

1 Answers1

0

Try this answer. Here I have wrapped .die divs by a parent div which has a .dies class. And also put .dies container and .btn container inside #dice-wrapper container.

    html,
    body {
      height: 100%;
    }
    
    .container {
      height: 100%;
    }
    
    #dice-wrapper {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 100%;
      border: cornflowerblue solid 1px;
    }

    .dies {
      display: flex;
      flex-direction: row;
    }
    
    .die img {
      max-width: 7rem;
    }
    
    .btn {
      display: flex;
      flex-direction: row;
      border: cornflowerblue solid 1px;
    }
     <body>
        <div class="container">
          <div id="dice-wrapper">
          <div class="dies">
            <div class="die">
              <input type="checkbox" id="dice-1" name="dice-1" value="dice-1" />
              <img src="img/dice-5.png" alt="Dice" class="dice1" id="dice-1" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-2" name="dice-2" value="dice-2" />
              <img src="img/dice-5.png" alt="Dice" class="dice2" id="dice-2" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-3" name="dice-3" value="dice-3" />
              <img src="img/dice-5.png" alt="Dice" class="dice3" id="dice-3" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-4" name="dice-4" value="dice-4" />
              <img src="img/dice-5.png" alt="Dice" class="dice4" id="dice-4" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-5" name="dice-5" value="dice-5" />
              <img src="img/dice-5.png" alt="Dice" class="dice5" id="dice-5" />
            </div>
            <div class="die">
              <input type="checkbox" id="dice-6" name="dice-6" value="dice-6" />
              <img src="img/dice-5.png" alt="Dice" class="dice6" id="dice-6" />
            </div>
            </div>
          <div class="btn">
            <button class="btn_roll">roll</button>
          </div>
          </div>
          
        </div>
        <script type="text/javascript" src="js/app.js"></script>
      </body>
    
  
VSM
  • 1,765
  • 8
  • 18