gpt4 book ai didi

html - 在背景图片下方显示内容

转载 作者:行者123 更新时间:2023-11-28 17:10:43 28 4
gpt4 key购买 nike

在我的主页上,我有一个全宽背景图片,但是,我的内容不会显示在它下面。相反,它显示在背景图像之上。谁能帮我让我的内容显示在我的背景图片下方?

这是我的 html 代码:

<html>
<title>PLR.com Home</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>

.homepage-backgroundimage {
z-index: -1;
position: absolute;
background-size: cover;
left:0; right:0; top:0;
margin-left: auto;
margin-right: auto;
display: block;
}

.flexcontainer-bodyarea {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
width: 1000px;
height: 500px;
background-color: #bbb;
}
.flexitem-50ptextarea {
width: 480px;
height: 200px;
margin: 10px;
background-color: #fff;
}

body {
font-family: 'Montserrat', sans-serif;
font-size: 36px;
color: #bbb;
}
</style>


<body>
<div class="homepage-backgroundimage"><img src="http://pianolessonresource.com/wp-content/uploads/2017/09/Untitled-1.jpg"></div>
<div class="flexcontainer-bodyarea">
<div class="flexitem-50ptextarea">This is one text area</div>
<div class="flexitem-50ptextarea">This is two text area</div>
</div>


</body>
</html>

最佳答案

让它成为一个真实的背景图片(在 CSS 规则中,而不是在图像标签中),删除那个 DIV 的绝对位置并给它 100% 的高度:

html,
body {
margin: 0;
height: 100%;
}

.homepage-backgroundimage {
background: url(http://pianolessonresource.com/wp-content/uploads/2017/09/Untitled-1.jpg) center, center;
background-size: cover;
height: 100%;
}

.flexcontainer-bodyarea {
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
width: 1000px;
height: 500px;
background-color: #bbb;
}

.flexitem-50ptextarea {
width: 480px;
height: 200px;
margin: 10px;
background-color: #fff;
}

body {
font-family: 'Montserrat', sans-serif;
font-size: 36px;
color: #bbb;
}
<div class="homepage-backgroundimage"></div>
<div class="flexcontainer-bodyarea">
<div class="flexitem-50ptextarea">This is one text area</div>
<div class="flexitem-50ptextarea">This is two text area</div>
</div>

关于html - 在背景图片下方显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46161293/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com