您的位置:首页 > Web前端 > CSS

css3 下拉缩放显示定位导航

2015-03-09 13:20 134 查看
简单的一个Demo:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body{height: 3000px;}
.box{
width: 100px;
height: 200px;
background-color: rgb(58, 119, 106);
position: absolute;
z-index: 1;
left: 100px;
top: 0;
-webkit-transition: all 0.3s;
transition: all 0.3s;
}
.transition{
/* 缩放 */
-webkit-transform: scale3d(0,0,1);
transform: scale3d(0,0,1);
/* 定中心点 */
-webkit-transform-origin: center center;
transform-origin: center center;
}
.fix{
position: fixed;
}
</style>
</head>
<body>
<div class="box transition" id="box"></div>
<script src="http://s.lamahui.com/jquery/jquery-2.1.1.min.js"></script>
<script>
$(function(){
$(window).scroll( function() {
var t = $(window).scrollTop();
if(t > 400){
$('#box').removeClass('transition').addClass('fix');
}else{
$('#box').addClass('transition').addClass('fix');
}
});
});
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: