页面中返回顶部效果

Original 2019-05-18 21:52:21 1534
abstract:<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="shortcut icon"  href="images/logo.ico" type="image/x-icon" />
<link rel="stylesheet" type="text/css" href="static/font-awesome/css/font-awesome.min.css">
<script type="text/javascript" src="static/js/jquery.min.js"></script>  

<style>
*{margin: 0px;padding: 0px;}
body{text-align: center;}
div{width: 1200px;height: 1500px;background: #eee;margin: 30px auto;}
a{text-decoration: none;color: #fff;}
p#back{text-align: center;position: fixed;bottom: 100px;right: 60px;background: #ccc;border-radius: 3px;height: 50px;width: 80px;display: none;}
p#back .fa{font-size: 30px;}
p a span:hover{background-color: red;}

</style>

<script>
    $(function() {
        $(window).scroll(function(){
            if($(window).scrollTop()>150){
                $('#back').fadeIn(1000)
            }else{
                $('#back').fadeOut(1000)
            }
        })
    })

</script>
</head>
<body>
    <a href=""></a>
    <div>网页内容</div>
    <p id="back"><a href=""><span class="fa fa-arrow-circle-up"></span><br> 返回顶部</a></p>
</body>
</html>


Correcting teacher:查无此人Correction time:2019-05-20 09:15:45
Teacher's summary:完成的不错。每行js语句结束增加;号。继续加油

Release Notes

Popular Entries