2011-11-22 74 views
1

我想要拿出一些CSS来匹配我在我的iPhone/Android应用程序中的样式。我有不透明的交替行颜色,所以我的自定义页面背景流血。但是,我遇到的问题是我不希望表单元格中的文本也不透明。我希望文本的透明度为1.0,背景为不透明度= 0.12。看到它现在看起来像here。下面CSS3交替表行不透明度影响文本以及背景

CSS:

html { 
    -webkit-background-size: cover; 
    -moz-background-size: cover; 
    -o-background-size: cover; 
    background-size: cover; 
    height: 100%; 
    background-image: url(../images/[email protected]); 
} 
table { 
    background-color: transparent; 
    margin-left: 0px; 
    margin-right: 0px; 
    margin-top: 10; 
    height: 100%; 
    width: 100%; 
    border: 0; 
    border-collapse: collapse; 
} 
tr { 
    text-align: center; 
    padding: 0; 
} 
td { 
    font-family: verdana; 
    color: #ffffff; 
    text-shadow: 1px 1px 1px #77777777, 2px 2px 7px #ff0000; 
    padding: 0; 
} 
tr:nth-child(odd) { background-color:#003366; opacity:.12; filter:alpha(12); } 
tr:nth-child(even)  { background-color:#6a737d; opacity:.12; filter:alpha(12); } 

回答

7

您可以使用rgba的颜色作为背景。 opacity会影响孩子的元素,并没有太多的事情要做。

+0

是的,工作。谢谢。 – LiteWait

0

使用rbga背景色(CSS3)并在其中设置不透明度。 background-color = rgba(255,255,255,0.12);

使用正常不透明度影响因素的孩子,所以文只是得到了父母的不透明度,在这种情况下是100%0.12

+0

是的,工作。谢谢。 – LiteWait

+2

正确但错误地引向读者。这不是它的继承(作为继承可以被重写)。它的事实是,你做出透明的东西,因此任何东西都将具有透明度。如果你让父母50%透明,孩子仍然100%可见。如果你让孩子透明度达到50%,你就可以让75%的孩子透明(50%的人达到50%)。关于主要文件的透明度 – Lee

+0

感谢您的意见 - 修改了措辞,试图使其更清晰。 – Helen

0

你也可以尝试把子元素在父面前元素使其不受父母不透明度的影响。

父:z-index:10 为孩子:z-index:11