I am facing a challenge understanding the layout of my div. My intention was to place a button at the bottom, so I adjusted the parent element's position to absolute
and set my element to have a relative
position. However, instead of appearing at the bottom as expected, it is positioned at the top. This behavior is perplexing, and I am struggling to comprehend why this is happening.
https://i.sstatic.net/rOTGc.png
Below is my HTML structure:
<!DOCTYPE html>
<html>
<head>
<style>
body{
background-color: #f3f2f4;
}
.header{
width: 105%;
height: 117px;
left: -11px;
position: absolute;
background-image: linear-gradient(#8bc2e0, #4f9bc6);
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 100% 70%;
border-bottom-right-radius: 100% 70%;
}
.container{
width:450px;
height:70vh;
background-color:white;
border-radius:6px;
position:absolute;
top:50%;
overflow:hidden;
left:50%;
transform:translate(-50%,-50%);
}
.logo {
width: 100px;
margin: 0 auto;
margin-top: 46px;
}
.button {
width: 80%;
margin: 0 auto;
padding: 15px 20px;
font-size: 17px;
color: #fff;
border-radius: 30px;
background: #428cb5;
display: flex;
align-items: center;
justify-content: center;
font-family: Arial;
cursor: pointer;
transition: .2s;
position: absolute;
bottom: 0px;
}
.button:hover {
background: #4895bf;
}
.body {
position: relative;
}
</style>
</head>
<body>
<div class="container">
<div class="body">
<div class="header">
<div class="logo">
</div>
</div>
<div class="button">Submit button</div>
</div>
</div>
</body>
</html>
Check out the fiddle here: https://jsfiddle.net/n35e6Lzh/