<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>div渐隐渐现</title>
</head>
<style>
#toggole {
transition: all 1s ease-in;
}
</style>
<body>
<div id="toggole">hello</div>
</body>
<script>
document.addEventListener('click', display);
function display() {
var obj = document.getElementById('toggole');
if (obj.style.opacity === '0') {
obj.style.opacity = '1';
} else {
obj.style.opacity = '0';
}
}
</script>
</html>
【每日一题】一个div块,设置其为两个效果,一个为渐隐效果,一个为点击空白处显示和隐藏
最新推荐文章于 2024-10-30 14:28:30 发布