网页返回顶部js代码+css

今天给大家分享个和网站一样的网页返回顶部js代码+css,返回顶部效果如上图。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS制作的返回网页顶部按钮代码</title>
<style type="text/css">
#goTopBtn {
bottom: 100px;
cursor: pointer;
height: 32px;
position: fixed;
right: 20px;
width: 32px;
background:url(2.png) no-repeat -32px 0px;
}
#goTopBtn:hover {
background:url(2.png) no-repeat 0px 0px;
}
</style>
</head>
<body style="height:1500px;">
<h2 style="text-align:center">网下拖动鼠标试试看</h2>
<!--效果开始-->
<div id="goTopBtn" style="display:none"></div>
<script language="javascript" type="text/ecmascript" src="scrolltop.js"></script>
<script type=text/javascript>goTopEx;</script>
</body>
</html>

有需要的可以评论区留下联系邮箱,直接给你发邮箱。

www.tstingmi.com 提供内容。