2013-02-23 76 views
0

我不希望子元素繼承父級不透明度。 [請在此輸入鏈接的描述] [1]重置某個元素的子元素的不透明度

[1]:http://jsfiddle.net/xALAW/的jsfiddle

<html> 

    <head></head> 
    <body> 

     <div class='hasopacity'> 
      This is the text with some opacity 
      <div class='noopacity'> 
       This is the text with no opacity 
      </div> 
     </div> 
</body> 

CSS

.hasopacity{opacity:0.5} 
.noopacity{opacity:1} 
+0

然後,據我所知,你必須讓它成爲兄弟姐妹而不是孩子。 – enhzflep 2013-02-23 08:06:21

+0

看看http://stackoverflow.com/questions/806000/transparent-background-but-not-the-content-text-images-inside-it-in-css-on – 2014-02-27 08:42:08

回答

2

子元素必須繼承父的不透明度設置。

我知道的唯一解決方案是讓通常是孩子的元素實際上是一個兄弟元素,它被定位爲看起來像是一個子元素。