我在div內定義了一個div,外部div具有一定的不透明性,這導致內部元素的z-index高於容器出現dim.IS的方式不能使即使外部div是div,內部div也顯得很暗淡。維護CSS內部元素的不透明度
下面的代碼
<body>
<style>
#cont{ background-color:yellow; width:900px; height:900px; margin:auto; padding:40px; position:relative; }
#top{ position:relative; background-color:orange; width:100%; padding:10px; }
#cont1{ background-color:black; width:800px; padding:20px; box-sizing:border-box; position:relative; z-index:3; opacity:0.4; }
#cont1_text{color:white; z-index:4; opacity:10; padding:20px; top:10px; }
#cont2{ background-color:blue; width:800px; padding:20px; box-sizing:border-box; position:relative; z-index:3; }
#butt{ position:relative; clear:both; }
</style>
<div id="cont">
<div id="cont1">
<div id="cont1_text">
The Last line of above code still shows the length of the array is 4, even though a element is deleted.HOW??
Well, the delete method just deletes the value from the defined position but the position still remains.It’s just like drinking coke, the liquid is gone after drinking(deleting) but the bottle remains. This creates a hole or leaves an empty space in the array.
</div>
</div>
<div id="cont2">
</div>
</div>
</body>
我知道實現期望的結果是通過不將內部的div外DIV中的一種方式。然後,將包含div的文本放置在容器div上方,方法是保持位置,頂部,左側等。但問題在於容器的高度不會隨着文本的長度而增加,因爲包含文本的div不在容器的div內。
輸出和編輯可以在這裏https://jsfiddle.net/sum1/av6r0aug/
我前陣子回答過類似的問題:http://stackoverflow.com/questions/27818804/setting-inner- div-opacity-to-1-but-not-affected – 2015-02-23 12:02:07