一個圖片的倒影效果

來源:互聯網
上載者:User
倒影
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>圖片倒影效果- Beautiful Style « 樣式之美 » loaoao.com </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="KEYWords" content="Reflection,canvas,filter,css,xhtml,effect" />
<meta name="DEscription" content="圖片倒影效果: IE是濾鏡做的的.Firefox1.5+ ,Opera9+ 是用canvas來處理的" />
<meta name="author" content="aoao" />
<meta content="all" name="robots" />
<link rel="start" href="http://http://www.alixixi.com/web/a/www.loaoao.com" title="Home" />
<script type="text/javascript">
 var draw=function(){
  var img=document.getElementById("gundam");
  var doc =document.getElementById("reflection");
  if (document.all && !window.opera) {
   var draw = document.createElement("DIV");
   draw.setAttribute("className","draw");
   doc.appendChild(draw);
  }
  else{
   var canvas = document.createElement("canvas");
   canvas.setAttribute("width",img.width);
   canvas.setAttribute("height",img.height);
   doc.appendChild(canvas);
   if (canvas.getContext){
    var test = canvas.getContext("2d");
    test.translate(0,img.height);
    test.scale(1,-1);
    test.drawImage(img, 0, 0,img.width,img.height);
    //test.globalCompositeOperation = "destination-out";
    var gradient = test.createLinearGradient(0, 0, 0, img.height);
    gradient.addColorStop(0, "rgba(255, 255, 255, 1.0)");
    gradient.addColorStop(1, "rgba(255, 255, 255, 0)");
    test.fillStyle = gradient;
    test.fillRect(0,0,img.width,img.height);
   }
  }
 }
 window.onload = draw;
</script>
<style type="text/css">
 #reflection{
 width:300px;
 margin:0 auto;
 }
 #gundam{
 display:block;
 }
 .draw{
 width:262px; height:240px;
   color:red;
    background:url("/UploadPic/2007-4/200741151936782.jpg") no-repeat ;
 filter:FlipV
 progid:DXImageTransform.Microsoft.Gradient(startColorStr='#FFFFFFFF', endColorStr='#00000000', gradientType='0');
 /*progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)*/
   }
</style>
</head>
<body>
<h1>圖片倒影效果</h1>
<p>IE是濾鏡做的的.Firefox1.5+ ,Opera9+ 是用canvas來處理的.傳說 Safari也支援canvas,可惜我沒環境.<br />
做完後才發現...原來人家早就把他封裝好了...
<a href="http://cow.neondragon.net/stuff/reflection/" title="Reflection.js 1.6 " >reflection 1.6</a>
. 不過..重要的是我在過程學到東西..
</p>
<div id="reflection">
<img id="gundam" src="/UploadPic/2007-4/200741151936782.jpg"/>
</div>
<p>canvas的相關資料<a href="http://developer.mozilla.org/en/docs/Canvas_tutorial">http://developer.mozilla.org/en/docs/Canvas_tutorial</div>
</a></p>
<p id="copyright">Copyright © 2006 <a rel="me" href="http://http://www.alixixi.com/web/a/www.loaoao.com/" title="Beautiful Style « 樣式之美 » http://www.alixixi.com/web/a/www.loaoao.com">aoao</a> .  <a rel="license" href="http://creativecommons.org/licenses/by/2.5/" title="知識共用組織">Some rights reserved</a>.</p>
</body>
</html>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.