我想要绝对定位一个文本在我的图片上方,但它似乎没有居中。我尝试了一些东西,但很奇怪。我想制作一个响应式网站,但是这样做开始看起来很奇怪。以下是我的代码。
HTML
HTML
<div id="container"></div>
<div class="parent">
<div class="child">
<h1> Richy Photography </h1>
</div>
</div>
CSS
#container {
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
background-image:url(image.jpg);
background-size:cover;
background-position:50% 50%;
background-repeat: no-repeat;
}
body, html
{
height:100%;
width:100%;
}
.parent {
position:relative;
font-family: Helvetica, Arial, sans-serif;
width: 100%;
height: 100%;
margin:0;
padding:0;
}
.child {
position: absolute;
left:37%;
top:37%;
margin:0;
padding:0;
}