I have set the "main" container to flex, and column. The button is not inside the "game" container, but it's being displayed inside the "game" container. I want these 3 items to be displayed in a column with no overlap. Why is it displaying with the button inside the "game" container?
<main>
<h1>Heads Up Poker</h1>
<div class='game'>
<div class='player2'>
<div >
<div >
</div>
<div class='board'>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
</div>
<div class='player1'>
<div >
<div >
</div>
</div>
<button>Deal!</button>
</main>
This is my CSS:
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
height: 100vh;
background-color: rgb(59, 59, 59);
display: flex;
align-items: center;
justify-content: center;
}
main {
background-color: rgb(23, 86, 23);
width: 98vw;
height: 98vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
h1 {
color: rgb(255, 231, 231);
font-size: 300%;
margin: 20px;
}
button {
background-color: rgb(197, 197, 197);
height: 85px;
width: 250px;
border-radius: 10px;
font-size: 30px;
box-shadow: 5px 5px 4px black;
transition: 0.2s;
}
button:hover {
background-color: rgb(150, 150, 150);
transition: 0.2s;
box-shadow: none;
}
.game {
border: 2px solid black;
height: 70%;
width: 90%;
}
CodePudding user response:
There are 4 closing </div>
tags missing, 2 inside player1
and 2 inside player2
.
Adding those, then the button is below the game
box. Try the runnable example below.
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Roboto", sans-serif;
height: 100vh;
background-color: rgb(59, 59, 59);
display: flex;
align-items: center;
justify-content: center;
}
main {
background-color: rgb(23, 86, 23);
width: 98vw;
height: 98vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-around;
}
h1 {
color: rgb(255, 231, 231);
font-size: 300%;
margin: 20px;
}
button {
background-color: rgb(197, 197, 197);
height: 85px;
width: 250px;
border-radius: 10px;
font-size: 30px;
box-shadow: 5px 5px 4px black;
transition: 0.2s;
}
button:hover {
background-color: rgb(150, 150, 150);
transition: 0.2s;
box-shadow: none;
}
.game {
border: 2px solid black;
height: 70%;
width: 90%;
}
<main>
<h1>Heads Up Poker</h1>
<div class='game'>
<div class='player2'>
<div ></div>
<div ></div>
</div>
<div class='board'>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
</div>
<div class='player1'>
<div ></div>
<div ></div>
</div>
</div>
<button>Deal!</button>
</main>
CodePudding user response:
You're just missing some closing div tags
<main>
<h1>Heads Up Poker</h1>
<div class='game'>
<div class='player2'>
<div ></div>
<div ></div>
</div>
<div class='board'>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
<div ></div>
</div>
<div class='player1'>
<div ></div>
<div ></div>
</div>
</div>
<button>Deal!</button>
</main>