這是我正在使用的代碼。我想要設置一個帶圖像背景的標題,但是當我設置正文背景時,它會消失:S。我做錯了什麼?當我設置身體背景時隱藏頭部
<body>
<div id="bg">
<img src="img/bodyBackground.png">
</div>
<header>
<div class="container">
<h1>Bienvenidos a JVasconcelos.me</h1>
</div>
</header>
</body>
這僅僅是HTML代碼,這裏是我使用的CSS:
#bg { position: fixed; top: -50%; left: -50%; width: 200%; height: 200%; }
#bg img { position: absolute; top: 0; left: 0; right: 0; bottom: 0; margin: auto; min-width: 50%; min-height: 50%; }
爲什麼'top:-50%'和'left:-50%'? – Chris