Recently I wanted to add a button inside a container along with icons and a text. But the button wont align in the middle. I'm not even sure if the icon is align at the middle. I tried adjusting the top % and left % but won't move.
.container {
position: relative;
width: 550px;
height: 350px;
background-color: rgba(255, 255, 255, 0.7);
margin: 20px auto;
border-radius: 15px;
box-shadow: 0 0 20px 0px rgba(0, 0, 0, 0.6);
}
.container h1 {
margin: 0;
padding: 0;
font-size: 30px;
text-align: center;
position: relative;
top: 20%;
transform: translateY(-80%);
}
.icon {
width: 40%;
height: 40%;
margin: 0;
left: 30%;
top: 15%;
transform: translateX(-70%, -80%);
position: relative;
}
.button {
background-color: rgba(231, 231, 231, 1);
border: none;
padding: 12px 25px;
margin: 0;
text-align: center;
display: block;
font-size: 16px;
color: black;
border-radius: 12px;
position: relative;
top: 50%;
left: 50%;
}
<div class="container">
<h1>Selamat Datang ke Kuiz FizikMudah!</h1>
<img src="https://via.placeholder.com/500x400.png" class="icon">
<a href="index.php"><button class ="button" type="button">Masuk</button></a>
</div>