I am simply trying to center my bg-text within the outer div, therefore having a picture in the background with the h1 tag in the center for all devices. I originally had this where the margin-top was a fixed pixel. I need it to be a percentage so it stays in the center. However, when i replaced the margin top with a percentage, as a minimize my screen the h1 element would slide upwards. I want it to stay margin-top: 50% of my background picture at all times.
HTML
<div class= 'bg'>
<div class='bg-text'>
<h1>Text</h1>
</div>
</div>
CSS
.
.bg {
display: table;
width: 100%;
height: 50%;
background-image: image-url('pic.jpg');
background-attachment: scroll;
background-position: center center;
background-repeat: no-repeat;
background-size: cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
}
.bg-text{
color: #fff;
text-align: center;
text-shadow: 1px 1px 12px rgba(0,0,0,0.5);
margin-top: 150px;
}
.bg-text h1{
font-size: 50px;
font-weight: 700;
}