我试图将图像覆盖在两个div col。上 - 我尝试使用Z-index。并且玩了我所知道的定位属性。
我做错了什么。两个框后面的三角形,以及您在JSFiddle中看到的其余文本,应位于径向渐变[ed]框的顶部。
#background-wrapper {
margin: 0 auto;
margin-top: 25px;
width: 1024px;
}
body {
background-color: #666;
}
body {
background-image: url("images/background-01.png");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
.container-01 {
position: absolute;
margin: 50px 50px;
width: 380px;
height: 160px;
opacity: .65;
background: #555; /* For browsers that do not support gradients */
background: -webkit-radial-gradient(circle, black, grey, white); /* Safari */
background: -o-radial-gradient(circle, black, grey, white); /* Opera 11.6 to 12.0 */
background: -moz-radial-gradient(circle, black, grey, white); /* Firefox 3.6 to 15 */
background: radial-gradient(circle, black, grey, white); /* Standard syntax */
z-index: 1
}
}
#trident {
clear: both;
left: 50px;
z-index: 2;
}
.container-01-box {
position: relative;
margin: 60px 60px;
width: 360px;
height: 140px;
background: #555; /* For browsers that do not support gradients */
background: -webkit-radial-gradient(circle, black, grey, white); /* Safari */
background: -o-radial-gradient(circle, black, grey, white); /* Opera 11.6 to 12.0 */
background: -moz-radial-gradient(circle, black, grey, white); /* Firefox 3.6 to 15 */
background: radial-gradient(circle, black, grey, white); /* Standard syntax */
z-index: 1
}
<title>UNAWAKENED.NET - Welcome!</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<section id="background-wrapper">
<header>_</header>
<div class="container-01"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Penrose-dreieck.svg/526px-Penrose-dreieck.svg.png" id="trident" alt="Triangle" width="100"><h1 id="top-box">Featured Dream</h1></div>
<div class="container-01-box"><h1 id="name-of-dream">"The ships from Nova"</h1></div>
</body>
如果有人好奇,那就是unawakened.net。如果顺便找到答案,请解释一下逻辑!
提前致谢。
答案 0 :(得分:1)
如果你想让Image保持在Top,那么你必须为IMG保留单独的div并保持Z-index比其他两个更大。请尝试或者您可以分享它的外观图像。 :)
答案 1 :(得分:1)
#background-wrapper {
margin: 0 auto;
margin-top: 25px;
width: 1024px;
}
body {
background-color: #666;
}
body {
background-image: url("images/background-01.png");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
}
.container-01 {
position: absolute;
margin: 50px 50px;
width: 380px;
height: 160px;
opacity: .65;
background: #555; /* For browsers that do not support gradients */
background: -webkit-radial-gradient(circle, black, grey, white); /* Safari */
background: -o-radial-gradient(circle, black, grey, white); /* Opera 11.6 to 12.0 */
background: -moz-radial-gradient(circle, black, grey, white); /* Firefox 3.6 to 15 */
background: radial-gradient(circle, black, grey, white); /* Standard syntax */
z-index: 2
}
}
#trident {
clear: both;
left: 50px;
z-index: 2;
}
.container-01-box {
position: relative;
margin: 60px 60px;
width: 360px;
height: 140px;
background: #555; /* For browsers that do not support gradients */
background: -webkit-radial-gradient(circle, black, grey, white); /* Safari */
background: -o-radial-gradient(circle, black, grey, white); /* Opera 11.6 to 12.0 */
background: -moz-radial-gradient(circle, black, grey, white); /* Firefox 3.6 to 15 */
background: radial-gradient(circle, black, grey, white); /* Standard syntax */
z-index: 1
}
<title>UNAWAKENED.NET - Welcome!</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<section id="background-wrapper">
<header>_</header>
<div class="container-01"><img src="https://upload.wikimedia.org/wikipedia/commons/thumb/c/c1/Penrose-dreieck.svg/526px-Penrose-dreieck.svg.png" id="trident" alt="Triangle" width="100"><h1 id="top-box">Featured Dream</h1></div>
<div class="container-01-box"><h1 id="name-of-dream">"The ships from Nova"</h1></div>
</body>