實現效果:固定導航欄的高度為整個屏幕高度;
實現二級導航在鼠標放在相應文字板塊,從右往左出現,
鼠標移開,子導航從左往右消失(把導航欄固定在左側,不用改js代碼,也是從左往右出現,從右往左消失)。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-3.1.1.min.js"></script>
<style>
*{
text-decoration: none;
color: black;
}
.right_nav {
width: 70px;
height: 100%;
background-color: lightpink;
position: fixed;
top: 0;
right: 1px;
z-index: 3;
}
.right_nav .a,.aa{
height: 40px;
line-height: 30px;
text-align: center;
margin:0;
padding: 0;
margin-bottom: 10px;
position: relative;
top:25%;
border: 1px solid mediumpurple;
}
.a:hover,.aa:hover {
background: mediumpurple;
}
.account {
width:100px ;
height: 30px;
position: absolute;
right: 69px;
top:10px;
border: 1px solid mediumpurple;
display: none;
}
.buy {
width:150px ;
height: 30px;
position: absolute;
border: 1px solid mediumpurple;
right: 69px;
top:7px;
display: none;
}
</style>
</head>
<body>
<div class="right_nav">
<div class="a">賬號
<div class="account ">
喲喲沒賬號
</div></div>
<div class="a">購物車
<div class="buy">去找孫空空辣</div>
</div>
<div class="aa"><a href="#top" >to top</a></div>
</div>
<script>
$(".a").hover(function () {
$(this).children().animate({width: 'toggle'});
})
</script>
</body>
</html>