2017-05-08 38 views
-3

我想div是透明的,但不是div內的按鈕。任何人都可以幫助我嗎?

#ss { 
 
    background-color: black; 
 
    width: 1500px; 
 
    height: 80px; 
 
    overflow-x: 0; 
 
    margin-top: -8px; 
 
    margin-left: -10px; 
 
    opacity: 0.5; 
 
    text-align: center; 
 
    position: absolute; 
 
} 
 

 
#as { 
 
    background-color: #968f8f; 
 
    width: 70px; 
 
    height: 40px; 
 
    opacity: 1; 
 
    margin-top: 15px; 
 
    position: relative; 
 
    color: white; 
 
    border-radius: 4px; 
 
} 
 

 
#bd { 
 
    background-color: grey; 
 
    background-image: url("image3.jpg"); 
 
    overflow-x: hidden; 
 
    background-repeat: no-repeat; 
 
    background-size: 1315px; 
 
}
<body id="bd"> 
 

 
    <div id="ss"> 
 

 
    <table> 
 
     <tr> 
 
     <td> 
 

 
      <button id="as"> Home </button> 
 

 
     </td> 
 

 
     </tr> 
 
    </table> 
 

 

 
    </div> 
 

 
</body>

的問題是,我想DIV是透明的,但不是在div裏面的按鈕。

+0

的[我不想在CSS的繼承父孩子不透明度]可能的複製(http://stackoverflow.com/questions/5770341/i-do-not-want-to-the-parent-in-css) – Ivar

+0

[透明父項中的非透明子項]的可能重複(http://stackoverflow.com/questions/3031848 /透明子透明父項) –

+0

由於除了按鈕之外,在div中沒有​​太多可以看到的東西,所以爲什麼不直接放棄不透明度並使用#7F7F7F作爲背景顏色。 –

回答

0

你父div元素移除背景顏色:background:rgba(0,0,0,.5)

+0

取決於你想要的:如果你想保持背景爲半黑色,使用'rgba 'bacgrkound,否則,只需刪除背景顏色。 – n1kkou

-1

首先:

#ss{ background:transparent; }

您還可以,如果你想保持DIV背景顏色使用rgba背景顏色從樣式標籤下的#ss中移除不透明屬性。

如果要完全刪除背景:
替換:
#ss { background-color:black; }
通過:
#ss { background:none; }

不然,如果你想的不透明度值設置爲背景:
替換:
#ss { background-color:black; }
通過:
#ss { background:rgba(0, 0, 0, desired_opacity_value); }
其中0(分鐘)< = desired_opacity_value < = 1(最大值)

+0

完全刪除了背景。 – Ivar

相關問題