JavaScript實現(xiàn)簡單的彈窗效果
更新時間:2020年05月19日 08:30:50 作者:安心寫bug
這篇文章主要為大家詳細介紹了JavaScript實現(xiàn)簡單的彈窗效果,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了JavaScript實現(xiàn)彈窗效果的具體代碼,供大家參考,具體內容如下
使用css動畫效果實現(xiàn)彈窗緩慢彈出和收回。
使用JavaScript實現(xiàn)定時彈出定時收回。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>簡單彈窗</title>
<style>
* {
margin: 0;
padding: 0;
}
.pop {
width: 400px;
height: 300px;
position: fixed;
bottom: 0;
right: 0;
display: none;
animation: pop 1s ease-in-out 0s;
}
@keyframes pop {
from {
height: 0;
}
to {
height: 300px;
}
}
.down {
width: 400px;
height: 0;
position: fixed;
bottom: 0;
right: 0;
display: block;
animation: out 1s ease-in-out;
}
@keyframes out {
from {
height: 300px;
}
to {
height: 0;
}
}
.img1 {
width: 400px;
height: 300px;
vertical-align: top;
}
</style>
</head>
<body>
<div class="pop" id="pop">
<img src="images/01.jpg" alt="" class="img1">
</div>
</body>
<script>
window.onload = function () {
timer = window.setInterval(imgBlock, 2000);
};
function imgBlock() {
var pop = document.getElementById('pop');
pop.style.display = 'block';
timer2 = window.setInterval(imgNone,5000);
}
function imgNone() {
var pop = document.getElementById('pop');
pop.className = 'down';
clearInterval(timer);
clearInterval(timer2);
}
</script>
</html>
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關文章
Javascript 函數(shù)parseInt()轉換時出現(xiàn)bug問題
天測試的測出來的。parseInt(1.13*100),實際返回值是112,下面有個示例,大家可以看看下2014-05-05
淺談使用splice函數(shù)對數(shù)組中的元素進行刪除時的注意事項
下面小編就為大家?guī)硪黄獪\談使用splice函數(shù)對數(shù)組中的元素進行刪除時的注意事項。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-12-12
javascript下拉列表中顯示樹形菜單的實現(xiàn)方法
這篇文章主要介紹了javascript下拉列表中顯示樹形菜單的實現(xiàn)方法,需要的朋友可以參考下2015-11-11

