1 Star 0 Fork 19

蝶飞依心/blog网页特效源码

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
js回到页面顶部.html 2.96 KB
一键复制 编辑 原始数据 按行查看 历史
北极光之夜 提交于 2021-09-27 22:19 . 'before-code'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot?wr5es');
src: url('fonts/icomoon.eot?wr5es#iefix') format('embedded-opentype'),
url('fonts/icomoon.ttf?wr5es') format('truetype'),
url('fonts/icomoon.woff?wr5es') format('woff'),
url('fonts/icomoon.svg?wr5es#icomoon') format('svg');
font-weight: normal;
font-style: normal;
font-display: block;
}
*{
font-family: 'icomoon';
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* body{
height: 500vh;
} */
.bg{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-image: url(img/11.jpg);
background-size: cover;
z-index: -10;
}
.zd{
position: fixed;
bottom: 50px;
right: -55px;
width: 50px;
height: 50px;
background-color: rgba(19, 117, 182,.8);
border-radius: 10px;
text-align: center;
line-height: 50px;
font-size: 25px;
color: aliceblue;
cursor: pointer;
user-select: none;
transition: all 0.5s;
}
.zd:hover{
color: rgb(35, 187, 15);
}
</style>
</head>
<body>
<div class="bg"></div>
<div class="zd"></div>
<div style="width: 500px; height: 500px; background-color: rgb(118, 33, 129);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(36, 129, 33);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(118, 33, 129);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(129, 107, 33);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(129, 33, 33);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(197, 146, 204);"></div>
<div style="width: 500px; height: 500px; background-color: rgb(41, 129, 33);"></div>
<script>
var zd = document.querySelector(".zd");
zd.addEventListener('click',function(){
var time = setInterval(function(){
let top = pageYOffset;
let step = Math.ceil(top/50);
window.scroll(0,top-step);
if(top==0){
clearInterval(time);
}
})
},30)
window.addEventListener('scroll',function(){
if(document.documentElement.scrollTop>0){
zd.style.right = 5 + 'px';
}else{
zd.style.right = -55 + 'px';
}
})
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/diefei-yixin/blog.git
git@gitee.com:diefei-yixin/blog.git
diefei-yixin
blog
blog网页特效源码
master

搜索帮助