I have a html file that when renders the text is bottom aligned. When the web-browser is open wide, the whole text is very far from the top as it can been seen here:
Now if I make the web-browser window narrower the text goes up like this:
Here is what I have in the html file:
<div class="post">
<h1>Title of Sample Work 2</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam dapibus id nisl ut suscipit. Nullam vel justo tellus. Suspendisse vehicula rhoncus nunc sed accumsan. In hac habitasse platea dictumst. Mauris vel dolor velit. Phasellus finibus massa mauris, at interdum nisl luctus at. Etiam porttitor, metus non dapibus pretium, orci arcu pretium nulla, eget congue augue libero at lectus. Mauris pretium urna tristique, laoreet enim rhoncus, euismod tortor.</p>
<p>Integer dolor nibh, blandit et suscipit in, egestas eu diam. Maecenas imperdiet posuere odio, et tempus sapien efficitur et. Aliquam nec augue efficitur, consectetur elit at, efficitur purus. Fusce sem augue, congue ac metus et, molestie tempus velit. Quisque vitae arcu porttitor, porta augue mollis, consectetur magna. Aenean ante orci, sagittis quis vehicula sit amet, finibus in risus. Sed eu elementum urna. Curabitur quis consequat nunc. Sed sollicitudin purus ac leo volutpat, sit amet rhoncus neque malesuada. Phasellus enim ante, ornare non sapien non, mattis sollicitudin lorem. Phasellus suscipit magna felis, sed ullamcorper tellus molestie ut. Phasellus tincidunt fringilla imperdiet. Fusce rhoncus ultrices sapien, vitae dignissim nunc tincidunt in.</p>
and here is what I have in the css:
.post {
margin-top: 5em;
margin-left: 2em;
margin-right: 2em;
}
.post p{
max-width: 1200px;
padding: .5em;
text-align: justify;
margin: 0;
top: 1.25em;
}
.post h1{
text-align: center;
}
I tried to add position: absolute;
to .post{
like this:
.post {
margin-top: 5em;
margin-left: 2em;
margin-right: 2em;
position: absolute;
}
but then it messes up left and right margins as it can be seen here:
As can be seen the right margin now is much smaller than left margin.
Any suggestion on how I align the text to the top without messing up left and right margin is really appreciated.