2015-12-15 109 views
0

我试图将图像覆盖在两个div列上 - 我尝试使用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如果有人好奇。如果你找到答案,请解释一下逻辑!

在此先感谢。

+1

[Rü这样看?差不多都是http://jsfiddle.net/sureshponnukalai/e73ys781/ –

+0

。我要检查你的代码。但是我希望元素完全在盒子上面。没有混合。 我看着它,你做了什么? :) – Sidhartha

+1

我刚刚改变了'z-index:1'到'z-index:100'为'container-01'类 –

回答

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>

1

如果你想Image保持最佳状态,那么你必须为IMG保留独立的div,并保持Z-index大于其他两个。请尝试或可以分享图片的外观。 :)

+0

我花了一些时间才弄清楚使用z-index首次。谢谢 – Sidhartha