我正在努力实现这个目标: https://www.dropbox.com/s/3zm1qssd3299uat/Social-Bottom.jpg
我想要一个位于背景div之上的内容div,如上图所示。
这是我目前的代码:
<!DOCTYPE html>
<html>
<head>
<title>VisionBeat DJ's Australia</title>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/nav.js"></script>
<LINK REL="SHORTCUT ICON" HREF="./favicon.ico">
<style>
@font-face {
font-family:"bold";
src: url('./fonts/bold.ttf');
}
@font-face {
font-family:"sbold";
src: url('./fonts/sbold.ttf');
}
@font-face {
font-family:"regular";
src: url('./fonts/regular.ttf');
}
@font-face {
font-family:"light";
src: url('./fonts/light.ttf');
}
@font-face {
font-family:"elight";
src: url('./fonts/elight.ttf');
}
html, body {
height: 100%;
width: 100%;
overflow:auto;
margin:0;
padding:0;
border:0;
font-family:'regular', sans-serif;
}
#bg1 {
height: 100%;
width: 100%;
background: url(./images/backgrounds/1.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index:0;
}
#bg2 {
height: 100%;
width: 100%;
background: url(./images/backgrounds/2.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index:1;
}
#bg3 {
height: 100%;
width: 100%;
background: url(./images/backgrounds/3.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
z-index:2;
}
h1 {
font-family:'bold', sans-serif;
font-weight:700;
color:#ecf0f1
}
h2 {
font-family:'sbold', sans-serif;
font-weight:600;
color:#ecf0f1
}
p1 {
font-family:'regular', sans-serif;
font-weight:400;
color:#ecf0f1
}
p2 {
font-family:'light', sans-serif;
font-weight:300;
color:#ecf0f1
}
a {
font-family:'elight', sans-serif;
font-weight:300;
color:#ecf0f1;
top:0;
bottom:0;
left:0;
right:0;
text-decoration:none
}
a:hover {
font-family:'elight', sans-serif;
font-weight:200;
color:#ecf0f1;
top:0;
bottom:0;
left:0;
right:0;
}
nav {
color:rgba(45, 45, 45, 0.5);
font-size:1.2em;
font-weight:300;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: -moz-none;
-ms-user-select: none;
user-select: none;
transition: border-color 0.5s ease;
border-top:1.5px solid;
border-color:rgba(45, 45, 45, 0);
}
nav a {
transition: border-color 0.5s ease;
border-top:1.5px solid;
border-color:rgba(45, 45, 45, 0);
}
nav a:hover {
border-color: rgba(236, 240, 241, 0.9)
}
#floater {
position:relative;
float:left;
height:50%;
margin-bottom:-100px;
width:1px;
}
#centered {
position:relative;
clear:left;
height:250px;
}
#centerfit {
text-align: center;
margin-left: auto;
margin-right: auto;
max-height: 250px;
}
#sticky_navigation_wrapper {
width:100%;
height:30px;
}
#sticky_navigation {
width:100%;
height:32px;
background-color:rgba(45, 45, 45, 0.75);
text-align:center;
-moz-box-shadow: 0 0 5px #999;
-webkit-box-shadow: 0 0 5px #999;
box-shadow: 0 0 5px #999;
}
</style>
</head>
<body>
<div id="bg1">
<div id="floater"></div>
<div id="centered">
<div id="centerfit">
<img src="images/logo.png" alt="VisionBeat Logo">
</div>
<div id="sticky_navigation_wrapper">
<div id="sticky_navigation">
<nav>
<a href="#Social"> Social </a>
<a href="#Contact"> Contact </a>
<a href="/"> Home </a>
<a href="#Events"> Events </a>
<a href="#Pricing"> Pricing </a>
</nav>
</div>
</div>
</div>
</div>
<section id="Social"></section>
<div id="bg2"></div>
</body>
答案 0 :(得分:0)
您要做的是在body标签上设置背景图片,并确保在为z-index
设置的元素上使用CSS定位。
我想你面临的问题是你的内容div不高于背景图像。尝试设置内容div绝对的定位,并确保在body标签上设置背景图像。