国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

javascript+jQuery實現360開機時間顯示效果

2019-11-19 14:59:48
字體:
來源:轉載
供稿:網友

實現效果:

實現原理:

  給關閉按鈕綁定點擊事件,點擊以后觸發動畫效果。利用jQuery的animate方法,先讓顯示天氣的盒子高度變為0,接著讓整個包含天氣和事件的盒子寬度變為0,最后通過將display屬性值設為none,使得close按鈕消失。

實現代碼:

<!DOCTYPE html><html><head> <title>仿360開機效果</title> <meta charset="utf-8"> <style type="text/css">  *{   padding: 0;   margin: 0;  }  .box{   width: 320px;   position: fixed;   bottom: 0;   right: 0;   box-shadow: 1px 1px 10px #2d2d2d;  }  #close{   position: absolute;   top: 0;   right: 0;   width: 30px;   height: 20px;   cursor: pointer;   background-color: red;   color: pink;   font-weight: bold;   text-align: center;  }  .hd{   width: 320px;   height: 300px;   background-color: #03c03c;   color: #fff;   font-size: 70px;   line-height: 300px;   text-align: center;  }  .bd{   width: 320px;   height: 100px;   background-color: #fffc00;   font-size: 30px;   line-height: 100px;   text-align: center;  } </style></head><body><div class="box"> <span id="close">X</span> <div class="hd" id="t">1分12秒</div> <div class="bd" id="b">天氣:晴天</div></div><!-- 引入jQuery --><script type="text/javascript" src="./jquery1.0.0.1.js"></script><script type="text/javascript"> window.onload = function(){  var close = document.getElementById("close");  var box = close.parentNode;  var b = document.getElementById("b");  // 給關閉按鈕綁定點擊事件  close.onclick = function(){   animate(b, {"height":0}, function(){    animate(box,{"width":0});   });   close.style.display = "none";  } }</script></body></html>

PS:JS 實現時間倒計時

<script type="text/javascript">var maxtime = 1350057600 //截止到的日期var now=parseInt((new Date().getTime())/1000);//獲取當前的日期var cha_time=maxtime-now;//中間所差的時間

下面方法把相差的時間組合成倒計時的字符串,然后放到頁面相應位置實現,實時刷新

function CountDown(){ if(cha_time>=0){var day = Math.floor(cha_time/3600/24);var hour= Math.floor((cha_time/3600)%24);var minutes = Math.floor((cha_time/60)%60); var seconds = Math.floor(cha_time%60); msg = "離結束還有"+day+"天"+hour+"小時"+minutes+"分"+seconds+"秒"; $(".ws_sg_con_big,.ws_sg_con_small").find("dd").html(msg);--cha_time; } else{ clearInterval(timer); alert("時間到,結束!"); } } timer = setInterval("CountDown()",1000); </script>

總結

以上所述是小編給大家介紹的javascript+jQuery實現360開機時間顯示效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 方城县| 渭南市| 江西省| 昭平县| 蒙阴县| 长宁区| 茌平县| 景德镇市| 那曲县| 东安县| 双桥区| 西充县| 新郑市| 青田县| 光泽县| 扎赉特旗| 湖北省| 洛隆县| 华安县| 松桃| 潮安县| 甘南县| 桐柏县| 沅江市| 罗江县| 南昌县| 苏尼特左旗| 五寨县| 本溪市| 达日县| 甘泉县| 滦平县| 改则县| 保康县| 台中市| 安丘市| 筠连县| 天门市| 平塘县| 阳朔县| 新野县|