分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

HTML 回到顶部 浮动

发布时间:2023-09-06 01:16责任编辑:沈小雨关键词:HTML
回到顶部
<div id="FloatDIV" style="position: absolute; top: 0px; z-index: 9999; background: #fff000; cursor: pointer;" onclick="window.scrollTo(0,0);">回到顶部</div><script type="text/javascript">// <![CDATA[var MarginLeft = 10; ???//浮动层离浏览器右侧的距离 ?var MarginTop = document.body.clientHeight - 80; ??//浮动层离浏览器顶部的距离(浏览器高度-div高度) ?var Width = 25; ???????????//浮动层宽度 ?var Heigth= 80; ??????????//浮动层高度 ???//设置浮动层宽、高 ?function Set() ?{ ?????document.getElementById("FloatDIV").style.width = Width + ‘px‘; ?????document.getElementById("FloatDIV").style.height = Heigth + ‘px‘; ?} ???//实时设置浮动层的位置 ?function Move() ?{ ???????var b_top = window.pageYOffset ?????????????????|| document.documentElement.scrollTop ?????????????????|| document.body.scrollTop ?????????????????|| 0; ???????var b_width= document.body.clientWidth; ?????document.getElementById("FloatDIV").style.top = b_top + MarginTop + ‘px‘; ?????document.getElementById("FloatDIV").style.left = b_width - Width - MarginLeft + ‘px‘; ?????setTimeout("Move();",100); ?} ???Set(); ?Move();// ]]></script>

参考:博客园

HTML 回到顶部 浮动

原文地址:http://www.cnblogs.com/aongao/p/7637281.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved