I'm trying to create a basic counter program. I have placed the label and buttons inside a div container and used flexbox styling on them. However, despite setting the display of the label to block and adding a line break after it, the buttons and label still appear on the same line. I actually want the buttons to be positioned below the number label.
Below is the code snippet:
HTML -:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Counter</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<label id="countLabel">0</label>
<br>
<div class="btns">
<button id="decrease">Decrease</button>
<button id="reset">Reset</button>
<button id="increase">Increase</button>
</div>
</div>
<script src="index.js"></script>
</body>
</html>
CSS -:
#countLabel{
display:inline-block;
text-align: center;
font-size: 70px;
}
.container{
display: flex;
justify-content: center;
align-items: center;
width: 100vw;
height: 100vh;
}
.btns{
display:flex;
justify-content: center;
}
#decrease{
margin:20px;
padding:10px;
font-family: 'Georgia';
font-size: 20px;
font-weight: bold;
background-color: rgb(245, 112, 72);
border:2px solid orange;
border-radius: 10px;
color:rgb(0, 0, 0);
}
#reset{
margin:20px;
padding:10px;
font-family: 'Georgia';
font-size: 20px;
font-weight: bold;
background-color: rgb(179, 167, 164);
border:2px solid rgb(70, 69, 69);
border-radius: 10px;
color:rgb(0, 0, 0);
}
#increase{
margin:20px;
padding:10px;
font-family: 'Georgia';
font-size: 20px;
font-weight: bold;
background-color: rgb(149, 241, 87);
border:2px solid rgb(1, 170, 15);
border-radius: 10px;
color:rgb(0, 0, 0);
}
Check out the output here -:
https://i.sstatic.net/1UG6D.png
Your assistance is highly appreciated.
Thanks!