css背景透明子元素不透明
1 <head> 2 <meta charset="utf-8"/> 3 4 <style> 5 body{ 6 position:relative; 7 } 8 #parent{ 9 position:absolute; 10 top:50px; 11 left:50px; 12 background-color:red; 13 opacity:0.5; 14 filter:Alpha(opacity=50);/*IE+兼容*/ 15 width:500px; 16 height:300px; 17 color:#fff; 18 } 19 #child{ 20 position:absolute; 21 top:0px; 22 left:0px; 23 background-color:#000; 24 color:#fff; 25 width:200px; 26 height:100px; 27 } 28 </style> 29 </head> 30 <body> 31 <div id="parent"> 32 父元素 33 <div id="child"> 34 子元素 35 </div> 36 </div> 37 </body>
注:opacity:0.1-1指-moz和webkit浏览器
filter:Alpha(opacity=50);/*IE+兼容*/
在css中层就想ps中的图层,z-index值得大小就如ps中图层的上下位置
if you don't try,you will never know!