I have three divs aligned to the center and the HTML and body area extend beyond the window to accomadate the last div which also adds a scroll bar.
What is wrong and how can I get over it?
Another question which is very similar but didn't solve the problem : Fixed Positioned Div is extending outside of HTML & Body
My code
html,
body {
margin: 0;
border: 0;
padding: 0;
width: 100%;
height: 100%;
position: relative;
}
p {
margin: 0;
padding: 0;
border: 0;
}
.top {
position: absolute;
margin: 0;
padding: 0;
left: 50%;
top: 0%;
transform: translate(-50%, 0%);
}
.center {
position: absolute;
margin: 0;
padding: 0;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.bottom {
position: absolute;
margin: 0;
padding: 0;
left: 50%;
top: 100%;
transform: translate(-50%, -0%);
}
<html>
<head>
<title>Position</title>
</head>
<body>
<div class="container">
<div class="top">
<p>I am top div</p>
</div>
<div class="center">
<p>I am center div</p>
</div>
<div class="bottom">
<p>I am bottom div</p>
</div>
</div>
</body>
</html>