直接上代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="format-detection" content="telphone=no, email=no">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="App-Config" content="fullscreen=yes,useHistoryState=yes,transition=yes">
<title>全球通客户俱乐部</title>
<!--引入swiper.css 滑动过渡用-->
<link rel="stylesheet" href="${miscDomain}/static/css/swiper.min.css">
<!--引入flexible.js rem自适应-->
<script src="${miscDomain}/static/js/flexible.js"></script>
<script src="${miscDomain}/static/zinfo/tool.js"></script>
<!--引入swiper.js-->
<script src="${miscDomain}/static/js/swiper.min.js"></script>
<link rel="stylesheet" href="${miscDomain}/static/css/gsm/common.css">
<link rel="stylesheet" href="${miscDomain}/static/css/gsm/index.css">
<style rel="stylesheet">
.national-div{
margin: 0 auto;
position: absolute;
left: 0;
top: 60px;
z-index:999;
margin: 50px;
}
</style>
</head>
<body class="index">
<!--要居中的div和img-->
<div id="national-div" class="national-div">
<img src="${mainDomain}/front/static/images/gsm/index/national.png" style="height:100%;width: 100%;">
</div>
</body>
<script src="${miscDomain}/static/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
$(function () {
//滚动条滚动事件
$(window).scroll(function() {
let top = $(window).scrollTop();
//每次滚动重新设置div的位置
$("#national-div").css("top",60+top+"px");
});
});
</script>
</html>
效果图