* {
margin:0;
padding:0;
}
.f {
width:100%;
height:100px;
background:red;
}
.div {
width:100%;
height:100px;
background:yellow;
}
.div1 {
width:100%;
height:1500px;
background:#393;
color:#fff;
}
.a {
position:fixed;
left:0;
top:0;
z-index:100;
-webkit-animation:searchTop .5s ease-in-out;
-moz-animation:searchTop .5s ease-in-out;
animation:searchTop .5s ease-in-out
}
@-webkit-keyframes searchTop {
0% {
top:-100px
}
to {
top:0
}
}@-moz-keyframes searchTop {
0% {
top:-100px
}
to {
top:0
}
}@keyframes searchTop {
0% {
top:-100px
}
to {
top:0
}
}代码很简单,但是在网站里面建议把window换成body,window的意思是窗口,它是指窗口大小的可视高度,不包括浏览器滚动条, 高度为document.documentelement.clientheight; document的意思是文档,它是指具体的一个对象的内容高度,高度为对象的document.documentelement.scrollheight; 在代码里面可以看到,body是包含在html里的,在标准浏览器里面html部分是等于body部分的。