I have been trying to set a text to center of a screen. so i placed a div with some text inside the body directly with some text and added height to it as 50% and margin-top as 50%. I thought it would hold the div's top position always at 50%. But i am wrong.
HTML:
<div id="test">test.. !</div>
CSS:
html, body {
width:100%;
height:100%;
margin:0;
}
div {
margin-top:50%;
text-align:center;
width:100%;
height:50%;
}
Do you have any ideas on why it is misbehaving? Please do not suggest any new ideas. I know other ideas for centering it. But I wonder why this snippet is not working.