HIỆU ỨNG RƠI CHO TOÀN BLOG

Người đăng: yeu mai em on Chủ Nhật, 11 tháng 12, 2011


Có nhiều cách để bạn trang trí cho blog mình thêm sinh động như: "sắm" đồng hồ hoặc một cuốn lịch dễ thương, tạo banner động, hình nền cho toàn blog...
Hôm nay, tôi xin giới thiệu với các bạn một thủ thuật khá hay là: Tạo hiệu ứng hình ảnh (động hoặc tĩnh) rơi trên toàn blog.
Mời các bạn xem thử (bấm vào XEM THỬ phía dưới để trải nghiệm nha)






Đầu tiên bạn đăng nhập vào Blog > chọn thiết kế > Thêm tiện ích HTML/Javacript rồi dán tất cả các code phía dưới vào và bấm Lưu lại




<script type="text/javascript">
  //Configure below to change URL path to the snow image
  var snowsrc="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaqJfTRrrd_FdsMBkGX9tifThhsHQyc2pUsW6JTbJOPgwmy1nSYmL6jIexqIZQzhoRehmUQOr8HGR0Lhh8e7U2dK51OwlWIwZZol-pydKZ8ae-K3KyePCgBmm3hSr9eFle_l6U5AbqPI/s1600/749701tyjg9brmps.gif"
  // Configure below to change number of snow to render
  var no = 10;
  // Configure whether snow should disappear after x seconds (0=never):
  var hidesnowtime = 0;
  // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  var snowdistance = "pageheight";

///////////Stop Config//////////////////////////////////

  var ie4up = (document.all) ? 1 : 0;
  var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }

  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 800, doc_height = 600;
 
  if (ns6up) {
    doc_width = self.innerWidth;
    doc_height = self.innerHeight;
  } else if (ie4up) {
    doc_width = iecompattest().clientWidth;
    doc_height = iecompattest().clientHeight;
  }

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();
  snowsrc=(snowsrc.indexOf("dynamicdrive.com")!=-1)? "snow.gif" : snowsrc
  for (i = 0; i < no; ++ i) {
    dx[i] = 0;                        // set coordinate variables
    xp[i] = Math.random()*(doc_width-50);  // set position variables
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*20;         // set amplitude variables
    stx[i] = 0.02 + Math.random()/10; // set step variables
    sty[i] = 0.7 + Math.random();     // set step variables
        if (ie4up||ns6up) {
      if (i == 0) {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><a href=\"http://dynamicdrive.com\"><img src='"+snowsrc+"' border=\"0\"><\/a><\/div>");
      } else {
        document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+snowsrc+"' border=\"0\"><\/div>");
      }
    }
  }

  function snowIE_NS6() {  // IE and NS6 main animation function
    doc_width = ns6up?window.innerWidth-10 : iecompattest().clientWidth-10;
        doc_height=(window.innerHeight && snowdistance=="windowheight")? window.innerHeight : (ie4up && snowdistance=="windowheight")?  iecompattest().clientHeight : (ie4up && !window.opera && snowdistance=="pageheight")? iecompattest().scrollHeight : iecompattest().offsetHeight;
    for (i = 0; i < no; ++ i) {  // iterate for every dot
      yp[i] += sty[i];
      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
      }
      dx[i] += stx[i];
      document.getElementById("dot"+i).style.top=yp[i]+"px";
      document.getElementById("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i])+"px";
    }
    snowtimer=setTimeout("snowIE_NS6()", 10);
  }

    function hidesnow(){
        if (window.snowtimer) clearTimeout(snowtimer)
        for (i=0; i<no; i++) document.getElementById("dot"+i).style.visibility="hidden"
    }
      

if (ie4up||ns6up){
    snowIE_NS6();
        if (hidesnowtime>0)
        setTimeout("hidesnow()", hidesnowtime*1000)
        }

</script>



Tiếp theo, bạn thay đổi link ảnh ở dòng lệnh màu đỏ và số lượng ảnh rơi ở dòng lệnh var no=10 theo ý thích của mình rồi bấm Lưu lại là xong.
Thủ thuật ở trên chỉ áp dụng cho một hình ảnh, còn bạn muốn rơi nhiều ảnh hơn nữa thì xem thủ thuật phía dưới (bấm vào Xem thử phía dưới).





Bạn cũng đăng nhập vào Blog > chọn Thiết kế > Thêm tiện ích HTML/Javacript rồi dán tất cả các code phía dưới vào.





<marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:601px;top:7px;width:auto;height:653px;z-index:1;" scrollamount="2"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCXR7Ah7ueGnXgX4GU8MaL8wYlCsB0sak2ievFStxmLeHk7d5MWBoZenhmZABZlMDOW8n6hRrnoOCJyNjOKCM75erLPlHPk6yBvvrRC07MzbAc_dLTs7q0GAnFM191wcmc7Y7vgKu7aVY/s1600/4.gif"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:720px;top:64px;width:auto;height:232px;z-index:1;" scrollamount="1"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:735px;top:50px;width:auto;height:321px;z-index:1;" scrollamount="1"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCXR7Ah7ueGnXgX4GU8MaL8wYlCsB0sak2ievFStxmLeHk7d5MWBoZenhmZABZlMDOW8n6hRrnoOCJyNjOKCM75erLPlHPk6yBvvrRC07MzbAc_dLTs7q0GAnFM191wcmc7Y7vgKu7aVY/s1600/4.gif&quot;/" /></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:608px;top:78px;width:auto;height:125px;z-index:1;" scrollamount="6"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:43px;top:62px;width:auto;height:10px;z-index:1;" scrollamount="1"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaqJfTRrrd_FdsMBkGX9tifThhsHQyc2pUsW6JTbJOPgwmy1nSYmL6jIexqIZQzhoRehmUQOr8HGR0Lhh8e7U2dK51OwlWIwZZol-pydKZ8ae-K3KyePCgBmm3hSr9eFle_l6U5AbqPI/s1600/749701tyjg9brmps.gif"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:539px;top:97px;width:auto;height:426px;z-index:1;" scrollamount=""><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:791px;top:45px;width:auto;height:178px;z-index:1;" scrollamount="3"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:278px;top:104px;width:auto;height:701px;z-index:1;" scrollamount="3"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:404px;top:69px;width:auto;height:211px;z-index:1;" scrollamount="2"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaqJfTRrrd_FdsMBkGX9tifThhsHQyc2pUsW6JTbJOPgwmy1nSYmL6jIexqIZQzhoRehmUQOr8HGR0Lhh8e7U2dK51OwlWIwZZol-pydKZ8ae-K3KyePCgBmm3hSr9eFle_l6U5AbqPI/s1600/749701tyjg9brmps.gif"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:331px;top:2px;width:auto;height:293px;z-index:1;" scrollamount="1"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:655px;top:89px;width:auto;height:399px;z-index:1;" scrollamount="7"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:813px;top:11px;width:auto;height:429px;z-index:1;" scrollamount="5"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:254px;top:109px;width:auto;height:146px;z-index:1;" scrollamount="7"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:616px;top:20px;width:auto;height:534px;z-index:1;" scrollamount=""><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaqJfTRrrd_FdsMBkGX9tifThhsHQyc2pUsW6JTbJOPgwmy1nSYmL6jIexqIZQzhoRehmUQOr8HGR0Lhh8e7U2dK51OwlWIwZZol-pydKZ8ae-K3KyePCgBmm3hSr9eFle_l6U5AbqPI/s1600/749701tyjg9brmps.gif"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:652px;top:42px;width:auto;height:410px;z-index:1;" scrollamount="1"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:707px;top:96px;width:auto;height:39px;z-index:1;" scrollamount=""><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:200px;top:76px;width:auto;height:137px;z-index:1;" scrollamount=""><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:309px;top:13px;width:auto;height:338px;z-index:1;" scrollamount="5"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEihaqJfTRrrd_FdsMBkGX9tifThhsHQyc2pUsW6JTbJOPgwmy1nSYmL6jIexqIZQzhoRehmUQOr8HGR0Lhh8e7U2dK51OwlWIwZZol-pydKZ8ae-K3KyePCgBmm3hSr9eFle_l6U5AbqPI/s1600/749701tyjg9brmps.gif"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:622px;top:107px;width:auto;height:676px;z-index:1;" scrollamount="5"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:149px;top:76px;width:auto;height:199px;z-index:1;" scrollamount="5"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee><marquee behavior="scroll" direction="down" style="position:absolute;border:0px;padding:0px;margin:0px;left:506px;top:77px;width:auto;height:344px;z-index:1;" scrollamount="5"><span class="falling1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_sfBTT8eXMloOh7kVzTRiKOqO9CdQ-PCgoyYDwlKMFV_YdtzQJBccS13zgCCnZgMwxNcjp-0jjRCTO6quMCK9Q-vkyOTvk1Bu1SBRq6Xf91GZlBSrBfRTINbut_p2Q3wzDIIj6aI_Rt4/"/></span></marquee>


Bây giờ, bạn thay đổi link ảnh ở dòng lệnh màu đỏ và bấm Lưu lại là xong.
Nếu muốn tìm ảnh động thì mời các bạn VÀO ĐÂY
Chúc các bạn thành công

{ 0 nhận xét... read them below or add one }

Đăng nhận xét