nav

$(document).ready(function() {
    $(window).resize(function(){
        var need=0;
        var ul_max_width = $(window).width()*0.96-$("#nav #admin").width();
        //alert(need + ‘, ul_max_width: ‘ + ul_max_width);
        need=$(‘#nav ul‘).width();
        if(ul_max_width<need){
            $("#nav .logo_name").html(‘CZ‘);
            $("#nav .logo_rear").html(‘‘);
             $(‘#nav ul nav_classification‘).removeClass(‘csshide‘);
             need=$(‘#nav ul‘).width();
             if(ul_max_width<need){
                var len = $(‘#nav ul li‘).length;
                while(--len>=0){
                    if($(this).attr(‘id‘) !=‘nav_classification‘){
                        need -= $(‘#nav ul li‘).eq(len).width();
                        alert(need);
                        $(‘#nav ul li‘).eq(len).addClass(‘csshide‘);
                        if(need<ul_max_width){ break;}
                    }
                }
             }
        } else {
            $("#nav .logo_name").html(‘carlo-z‘);
            $("#nav .logo_rear").html(‘.com‘);
        }
    });

});
#nav
{
    background: #65666D;
    padding-left: 2%;
    padding-right: 2%;
    margin: 0;
    overflow:hidden;
}
#nav ul
{
}
#nav ul li
{
    float: left;
    height: 40px;
}
#nav a
{
    position: relative;
    display: block;
    outline: 0;
    float: left;
    color: #fff;
    font-size: 16px;
    height: 40px;
    line-height: 40px;
    _line-height: 40px\9;
    overflow: hidden;
    margin: 0 auto;
    z-index: 1000;
    zoom: 1;
    padding: 0 22px 0 23px;
    text-decoration: none;
}
#nav a:visited
{
    color: #fff;
}
#nav a:hover
{
    background: #55575c;
    border-left: 1px solid #4e5155;
    border-right: 1px solid #4e5155;
    padding: 0 22px;
    margin-right: -1px;
    z-index: 1001;
}
#nav #admin
{
    display: inline-block;
    width: auto;
    height: 40px;
    float: right;
    background-color: #4DBE39;
}

#nav .logo{padding: 0; margin: 0; border: 0; overflow: hidden;}
#nav .logo_name{font-size: 32px; font-weight: bold; color: #FFFFFF;}
#nav .logo_rear{font-size: 21px; font-weight: bold; color: #4DBE39;}

#nav .csshide{display:none;}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
    <link href="../base.css" rel="stylesheet" type="text/css" />
    <link href="moudle_nav.css" rel="stylesheet" type="text/css" />

    <script src="../jquery-2.1.3.min.js" type="text/javascript"></script>
    <script src="moudle_nav.js" type="text/javascript"></script>
    <link href="../atb_mystyle/common_atb.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="nav">
        <ul>
            <li id="nav_logo"><a href="">
                <span class="logo">
                    <span class="logo_name">carlo-z</span> <span class="logo_rear">.com</span>
                </span>
            </a></li>
            <li><a href="">Android</a></li>
            <li><a href="">Linux</a></li>
            <li><a href="">Web</a></li>
            <li><a href="">Cloud</a></li>
            <li><a href="">Android</a></li>
            <li><a href="">Linux</a></li>
            <li><a href="">Web</a></li>
            <li><a href="">Cloud Computing</a></li>
            <li id="nav_classification" class="csshide"><a href="">Classification</a></li>
        </ul>
        <a id="admin" href="">Admin</a>
    </div>
</body>
</html>
时间: 2024-10-17 12:36:14

nav的相关文章

1-3、nav元素

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>nav</title> </head> <body> <h1>技术资料</h1> <nav> <ul> <li><a href="#">主页</a></li>

yii NAV x下拉

$menuItems[] = [ 'label' => "<img src='/images/small.jpg'>", 'url' => ['/site/logout'], 'linkOptions' => ['class' => 'avatar'], 'items'=>[ [ 'label'=>'Home1', 'url'=>'/site/index' ], [ 'label'=>'Home2', 'url'=>'/

ThinkCMF-首页Nav部分菜单配置详解

Nav菜单代码放在了 /themes/simplebootx/Public/nav.html 具体代码: <?php $effected_id="main-menu"; $filetpl="<a href='\$href' target='\$target'>\$label</a>"; $foldertpl="<a href='\$href' target='\$target' class='dropdown-toggl

jquery 根据网站url给导航nav添加active效果

后台的同事因为把nav公用了,所以无法单页添加active,一下方法通过判断url的后缀给当前页添加active $(function(){ var _nava= $('.nav .nav-wrapper a'); var _url = window.location.href; var _host = window.location.host; for(var i = 0; i<_nava.length ; i++){ var _astr = _nava.eq(i).attr('href');

纯CSS实现nav导航栏+jQuery实现article区DIV切换

效果图: main.html 代码: 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>MyHomepage</title> 5 <meta charset="utf-8" /> 6 <link type="text/css" rel="stylesheet" href="css/reset.css" />

nav标签的作用

. <nav>用来将具有导航性质的链接划分在一起,使代码结构在语义化方面更加准确,同时对于屏幕阅读器等设备的支持也更好.一直以来,我们习惯于使用形如<div id="nav">或<ul id="nav">这样的代码来写页面的导航:在HTML5中,我们可以直接将导航链接列表放到<nav>标签中: <nav><a>首页</a><a>文章</a><a>关

nav ccsss

/*header: Navigation public style*/header:before, header:after ,.navigation:before, .navigation:after,.nav-row:before, .nav-row:after,.top-bar:before, .top-bar:after{ content: " "; display: table;}header:after,.navigation:after,.nav-row:after,.t

jquery实现nav的下拉

<script type="text/javascript"> $(function(){ //tab_flag 根据此标记判断是否由父级nav指向了nav_list var tab_flag = false; var nav_col = $('.nav_col');var nav_list = $('.nav_list'); var nav_list_col = $('.nav_list_col'); //父级nav 颜色变换 function nav_col_cb(_t

iOS:NAV+TABLE结合

功能:点击列表项,用列表字符串作为参数创建一个新视图,新视图默认可以有一个BACK按钮回到上一个视图 // // main.m // Hello // // Created by lishujun on 14-8-28. // Copyright (c) 2014年 lishujun. All rights reserved. // #import <UIKit/UIKit.h> // ------------- 接受参数的视图控制器------------- @interface TestV

Bootstrap 3之美05-排版、Button、Icon、Nav和NavBar、List、Table、Form

本篇主要包括: ■  排版■  Button■  Icon■  Nav和NavBar■  List■  Table■  Form 排版 ● 斜体:<em>● 加粗体:<strong>● 突出段落:class="lead"● 字体颜色:class="text-success",class="text-muted",class="text-success",class="text-primary&