首页 > 代码库 > 背景色透明,内容不透明,适用所有浏览器(转)

背景色透明,内容不透明,适用所有浏览器(转)

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 4 <head> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 6 <title>Css:背景色透明,内容不透明之终极方法!兼容所有浏览器</title> 7 <style type="text/css"> 8 *{margin:0;padding:0;} 9 body{background:#3f3f3f;font-family:"宋体", Arial;}10 h1, h2, h3, h4, h5, h6{font-weight:normal;font-size:100%;}11 img{border:none 0;}12 #bos{width:820px;background:#fff;margin:0 auto;}13 #bos ul{zoom:1;overflow:hidden;background:#fff;padding:5px 0 5px 5px;}14 #bos ul li{width:260px;position:relative;overflow:hidden;float:left;margin:5px;background:#fff;}15 .img_wrap{width:258px;border:1px solid #ccc;border-radius:15px;display:block;overflow:hidden;}16 #bos ul li h2{width:100%;height:0px;line-height:50px;color:#fff;text-indent:1em;font-size:14px;font-family:微软雅黑;position:absolute;bottom:0px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;filter:progid:DXImageTransform.Microsoft.gradient(enabled=‘true‘,startColorstr=‘#44000000‘,endColorstr=‘#44000000‘);background:rgba(0,0,0,.6);}17 </style>18 </head>19 <body>20   <div id="bos">21     <ul>22       <li>23         <a class="img_wrap" href="#"><img src="http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg" alt="" /></a>24         <h2>网站防诈骗重要提示 购物满59元免运费</h2>25       </li>26       <li>27         <a class="img_wrap" href="#"><img src="http://i1.vanclimg.com/users/18/20120824/r1_120824.jpg" alt="" /></a>28         <h2>Android客户端升级新体验 配送延误通知</h2>29       </li>30       <li>31         <a class="img_wrap" href="#"><img src="http://i1.vanclimg.com/users/18/20120824/f8_120824.jpg" alt="" /></a>32         <h2>陈年谈品牌的本分 工行e支付可直减60元</h2>33       </li>34       <li>35         <a class="img_wrap" href="#"><img src="http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg" alt="" /></a>36         <h2>陈年谈品牌的本分 工行e支付可直减60元</h2>37       </li>38       <li>39         <a class="img_wrap" href="#"><img src="http://i1.vanclimg.com/users/18/20120824/f8_120824.jpg" alt="" /></a>40         <h2>陈年谈品牌的本分 工行e支付可直减60元</h2>41       </li>42       <li>43         <a class="img_wrap" href="#"><img src="http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg" alt="" /></a>44         <h2>陈年谈品牌的本分 工行e支付可直减60元</h2>45       </li>46   </ul>47 </div>48   <script type="text/javascript">49      var bos = document.getElementById(bos);50      var lis = bos.getElementsByTagName(li);51      var len = lis.length;52      while (len--) {53          lis[len].onmouseover = function () {54              over(this.getElementsByTagName(h2)[0]);55          }56          lis[len].onmouseout = function () {57              out(this.getElementsByTagName(h2)[0]);58          }59      }60      function over(obj) {61          var ypos = 0;62          if (obj.time) {63              clearInterval(obj.time)64          }65          obj.time = setInterval(function () {66              if (ypos < 50) {67                  ypos += Math.ceil((50 - ypos) / 3);68              }69              obj.style.height = ypos + "px";70          }, 25);71      }72      function out(obj) {73          var ypos = 50;74          if (obj.time) {75              clearInterval(obj.time)76          }77          obj.time = setInterval(function () {78              if (ypos >= 0) {79                  ypos -= Math.ceil((ypos - 0) / 3);80              }81              obj.style.height = ypos + "px";82          }, 25);83      }84      // js代码解释权归华仔所有85 </script></body>86 </html>

 如何在博客园里放入可运行的代码啊??还没搞明白.....

 

转自:http://www.cnblogs.com/jikey/archive/2012/08/31/2665880.html

背景色透明,内容不透明,适用所有浏览器(转)