CSS:
.header{
position: absolute;
top: 50%;
left: calc(50% - 200px);
opacity: 0.9;
color: #ffffff;
font-size: 35px;
text-shadow: 2px 2px 5px #000000;
}
HTML:
<body>
<div class="background"></div>
<div style="position: relative">
<div class="header"><label>A+ CMS</label></div>
</div>
</body>
Output:
The left
property has works properly, but top
property doesn't. I set 50% to top
but the word "A+ CMS" keeps hang on the top of the screen.
If I change the value of top
from percentage to px
, it works. Why?