javascript+jQuery實現(xiàn)360開機時間顯示效果
實現(xiàn)效果:

實現(xiàn)原理:
給關(guān)閉按鈕綁定點擊事件,點擊以后觸發(fā)動畫效果。利用jQuery的animate方法,先讓顯示天氣的盒子高度變?yōu)?,接著讓整個包含天氣和事件的盒子寬度變?yōu)?,最后通過將display屬性值設為none,使得close按鈕消失。
實現(xiàn)代碼:
<!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");
// 給關(guān)閉按鈕綁定點擊事件
close.onclick = function(){
animate(b, {"height":0}, function(){
animate(box,{"width":0});
});
close.style.display = "none";
}
}
</script>
</body>
</html>
PS:JS 實現(xiàn)時間倒計時
<script type="text/javascript"> var maxtime = 1350057600 //截止到的日期 var now=parseInt((new Date().getTime())/1000);//獲取當前的日期 var cha_time=maxtime-now;//中間所差的時間
下面方法把相差的時間組合成倒計時的字符串,然后放到頁面相應位置實現(xiàn),實時刷新
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 = "離結(jié)束還有"+day+"天"+hour+"小時"+minutes+"分"+seconds+"秒";
$(".ws_sg_con_big,.ws_sg_con_small").find("dd").html(msg);
--cha_time;
}
else{
clearInterval(timer);
alert("時間到,結(jié)束!");
}
}
timer = setInterval("CountDown()",1000);
</script>
總結(jié)
以上所述是小編給大家介紹的javascript+jQuery實現(xiàn)360開機時間顯示效果,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
相關(guān)文章
JAVASCRIPT實現(xiàn)的WEB頁面跳轉(zhuǎn)以及頁面間傳值方法
在WEB頁面中,我們實現(xiàn)頁面跳轉(zhuǎn)的方法通常是用LINK,BUTTON LINK ,IMG LINK等等,由用戶點擊某處,然后直接由瀏覽器幫我們跳轉(zhuǎn)。2010-05-05
firefox 和 ie 事件處理的細節(jié),研究,再研究 書寫同時兼容ie和ff的事件處理代碼
firefox 和 ie 事件處理的細節(jié),研究,再研究 書寫同時兼容ie和ff的事件處理代碼2007-04-04
Web網(wǎng)站都變成灰色有哪些方法可以快速實現(xiàn)(解決方案)
有些時候我們需要把網(wǎng)站頁面變成黑白色或灰色,特別是對于一些需要悼念的日子,以及一些影響力很大的偉人逝世或紀念日的時候,都會讓網(wǎng)站的全部網(wǎng)頁變成灰色(黑白色),以表示我們對逝者或者英雄的緬懷和悼念2022-12-12
微信小程序結(jié)合mock.js實現(xiàn)后臺模擬及調(diào)試
這篇文章主要介紹了微信小程序結(jié)合mock.js實現(xiàn)后臺模擬及調(diào)試,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2019-03-03

