html炫酷导航实例,CSS+JQ实现炫酷导航栏

1.当前页面高亮显示的导航栏

导航栏一

首页

*{ margin:0; padding: 0; }

a{ text-decoration: none; }

.nva{ width: 100%; height: 40px; margin-top: 70px; background-color: #222; }

.list{ width: 80%; height: 40px; margin: 0 auto; list-style-type: none; }

.list li{ float: left; }

.list li a{ padding: 0 30px; color: #aaa; line-height: 40px; display: block; }

.list li a:hover{ background:#333; color:#fff; }

.list li a.on{ background:#333; color:#fff; }

h1{ margin: 20px auto; text-align: center; }

$(function(){

//当前链接以/分割后最后一个元素索引

var index = window.location.href.split("/").length-1;

//最后一个元素前四个字母,防止后面带参数

var href = window.location.href.split("/")[index].substr(0,4);

if(href.length>0){

//如果匹配开头成功则更改样式

$(".list li a[href^='"+href+"']").addClass("on");

//[attribute^=value]:匹配给定的属性是以某些值开始的元素。

}else {

//默认主页高亮

$(".list li a[href^='index']").addClass("on");

}

});

2.划入自动切换的导航条

*{ margin:0; padding: 0; }

a{ text-decoration: none; }

.nva{ width: 100%; height: 40px; margin-top: 70px; background-color: #222; overflow: hidden; }

.list{ width: 80%; height: 40px; margin: 0 auto; list-style-type: none; }

.list li{ float: left; }

.list li a{ padding: 0 30px; color: #aaa; line-height: 40px; display: block; transition: 0.3s; }

.list b,.list i{ display: block; }

.list li a:hover{ margin-top: -40px; background:#333; color:#fff; }

.list li a.on{ background:#333; color:#fff; }

h1{ margin: 20px auto; text-align: center; }

$(function () {

$(".list a").hover(function () {

//stop是当执行其他动画的时候停止当前的

$(this).stop().animate({

"margin-top": -40

},300);

},function () {

$(this).stop().animate({

"margin-top": 0

},300);

});

});

3.弹性子菜单实现

Android

*{ margin:0; padding: 0; }

a{ text-decoration: none; }

.nva{ width: 100%; height: 40px; margin-top: 70px; background-color: #222; position: relative; }

.list{ width: 80%; height: 40px; margin: 0 auto; list-style-type: none; }

.list li{ float: left; }

.list li a{ padding: 0 30px; color: #aaa; line-height: 40px; display: block; transition: 0.3s; }

.list b{ display: block; }

.list li a:hover{ background:#333; color:#fff; }

.list li a.on{ background:#333; color:#fff; }

.list .down{ position: absolute; top: 40px; background-color: #222; /*display: none;*/ }

.list .down a{ color: #aaa; padding-left: 30px; display: block; }

h1{ margin: 20px auto; text-align: center; }

$(function () {

$(".list li").hover(function () {

//这里使用了easing插件

$(this).find(".down").stop().slideDown({duration:1000,easing:"eaSEOutBounce"});

},function () {

$(this).find(".down").stop().slideUp({duration:1000,easing:"eaSEOutBounce"});

});

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值