顶部搜索框显示与隐藏。回到顶部
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title>搜索框</title>
<style>
*{
margin:0;
padding:0;
border:0;
}
body,html{
}
.mina{
width:750px;
margin:0 auto;
position: relative;
background: palegreen;
}
.header-search-form1{
width: 100%;
height:50px;
position: fixed;
top:0;
}
.header-search-form1>div>input{
width:400px;
height:30px;
text-align: center;
background:pink;
}
section{
width:750px;
height: 600px;
background: red;
}
article{
width:750px;
height: 1600px;
background: deeppink;
}
aside img{
position: fixed;
top:80%;
right:0;
}
</style>
</head>
<body>
<div class="mina">
<div class="header-search-form1">
<div>
<input type="text" placeholder="输入你产品" id="index_newkeyword" />
</div>
</div>
<section>
dsdsdssdasdaDFASFDASF
</section>
<article>
1111111asdaDFASFDASF
</article>
<aside>
<img src="img/1_07.png" alt="" />
</aside>
</div>
<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
$(function(){
$(window).scroll(function(){
var witop=$(document).scrollTop();
if(witop>46){
$(".header-search-form1").css({"background":"yellow","posotion":"fixed","top":"0"})
}else{
$(".header-search-form1").css({"background":"orange","posotion":"absolute","top":"0"})
}
if(witop>300){
$("aside>img").css('display','block')
}else{
$("aside>img").css('display','none')
}
});
$("aside>img").click(function(){
$(document).scrollTop(0)
})
})
</script>
</body>
</html>