如何克服CSS中的透明度方面

时间:2013-09-13 06:35:51

标签: html css

我的理解是,当将透明度方面放在元素上时,不透明度始终保持在最顶层。我的问题是:将元素放在不透明度之上的最佳方法是什么。

这是Jsfiddle:http://jsfiddle.net/6xV4B/

HTML:

<div id="header">
   <ul id="social" class="center">
       <li><a href="#"><img src="images/facebook.png" alt="Facebook Icon" /></a></li>
       <li><a href="#"><img src="images/twitter.png" alt="Twitter Icon" /></a></li>
       <li><a href="#"><img src="images/linkedIn.png" alt="linkedIn Icon" /></a></li>
    </ul>
</div>

<div id="backgroundOne">
    <div id="backgroundTwo" class="center"></div>
</div>

<div id="blankTile1"></div>

<div id="myPicture" class="center">
    <div id="logo"></div>
</div>

<div id="blanktileTwo"></div>

这是CSS:

#header {
    width: 100%;
    height: 250px;
    background-color: #643b0f;
    opacity: .5;
}
#social {
    width: 1050px;
    margin: 0 auto;
}
#social li {
    display: inline-block;
    margin: 50px 0 0 50px;
}
#social li a {
    padding: 0 50px;
}
#backgroundOne {
    width: 100%;
    height: 1200px;
    background-color: blue;
    background-repeat: no-repeat;
    background-size: cover;
}
#myPicture {
    width: 650px;
    height: 955px;
    margin: -1200px 0 0 325px;
    position: absolute;
    display: block;
    background-color: yellow;
}
#backgroundTwo {
    width: 960px;
    height: 1200px;
    background-color: #000;
    opacity: .5;
}
#logo {
    background-color: green;
}
#blankTile1 {
    width: 100%;
    height: 478px;
    background-color: transparent;
}
#blankTile2 {
    width: 100%;
    height: 478px;
    background-color: transparent;
}

(为了进一步理解 - 这是视差项目的开始。这是为了学习这种技术。)

1 个答案:

答案 0 :(得分:1)

喜欢这个

因此,一个solution是使用一个微小的透明PNG作为重复的背景图像来解决这个问题。唯一的问题是IE6,并且有Links