推荐于2018-02-28
展开全部
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>menu</title>
<style type="text/css">
body {
height: 2000px;
}
div#hello {
position: fixed;
top: 300px;
width: 100%;
height: 30px;
border: 1px solid black;
display: none;
}
</style>
<script type="text/javascript">
onscroll = function ()
{
var st = document.documentElement.scrollTop || document.body.scrollTop;
if (!hello.offsetWidth && st >= 300)
{
hello.style.display = 'block';
}
else if (!!hello.offsetWidth && st < 300)
{
hello.style.display = 'none';
}
}
</script>
</head>
<body>
<div id="hello">Hello World!</div>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="js/jquery-2.1.1.min.js"></script>
<style>
.page{height:500px;width:500px;margin:0 auto;background-color:#CC9;overflow:hidden;overflow-y:auto;position:relative;}
.scroll{width:100%;height:800px;background-color:#e1e1e1;}
.show{width:200px;height:200px;background-color:#993;position:fixed;left:500px;top:100px;display:none;}
</style>
</head>
<body class="">
<div class="page">
<div class="scroll">
<div class="show"></div>
</div>
</div>
</body>
<script>
$(document).ready(function(){
$(".page").scroll(function(){
var scroll_top=$(".page").scrollTop();
if(scroll_top>=100){$(".show").css("display","block");}
else{$(".show").css("display","none");}
})
})
</script>
</html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<script src="js/jquery-2.1.1.min.js"></script>
<style>
.page{height:500px;width:500px;margin:0 auto;background-color:#CC9;overflow:hidden;overflow-y:auto;position:relative;}
.scroll{width:100%;height:800px;background-color:#e1e1e1;}
.show{width:200px;height:200px;background-color:#993;position:fixed;left:500px;top:100px;display:none;}
</style>
</head>
<body class="">
<div class="page">
<div class="scroll">
<div class="show"></div>
</div>
</div>
</body>
<script>
$(document).ready(function(){
$(".page").scroll(function(){
var scroll_top=$(".page").scrollTop();
if(scroll_top>=100){$(".show").css("display","block");}
else{$(".show").css("display","none");}
})
})
</script>
</html>
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询