一款纯css3实现的响应式导航

之前为大家介绍了好几款响应式导航。今天再给大家带来一款纯css3实现的响应式导航。这款导航还有个响应式的搜索框。废话少说,直接上图:

在线预览   源码下载

实现的代码。

html代码:

 <div class="navbar">
            <a class="brand" href="#">
                <img src="logo.png" /></a>
            <!--MOBILE-->
            <div class="navbar-mobile hidden-desktop">
                <ul class="    nav">
                    <li class="mobile-dropdown"><i class="icon-reorder"></i>
                        <div class="mobile-menu">
                            <div class="menu-wrapper">
                                <ul class="mobile-nav">
                                    <li><a href="http://www.w2bc.com">Home</a></li>
                                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Add
                                        Profile<span class="icon-angle-down"></span></a>
                                        <ul class="dropdown-menu">
                                            <li><a href="/twitter/oauth">Twitter</a></li>
                                            <li><a href="/facebook/oauth">Facebook</a></li>
                                            <li><a href="/googleplus/oauth">Google Plus</a></li>
                                            <li><a href="/instagram/oauth">Instagram</a></li>
                                        </ul>
                                    </li>
                                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Create<span
                                        class="icon-angle-down"></span></a>
                                        <ul class="dropdown-menu">
                                            <li><a href="/createStream">Create Stream</a></li>
                                            <li><a href="/createAlbum">Create Album</a></li>
                                            <li><a href="/createGroup">Create Group</a></li>
                                        </ul>
                                    </li>
                                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View<span
                                        class="icon-angle-down"></span></a>
                                        <ul class="dropdown-menu">
                                            <li><a href="/viewStreams">View Streams</a></li>
                                            <li><a href="/viewAlbums">View Albums</a></li>
                                            <li><a href="/viewGroups">View Groups</a></li>
                                        </ul>
                                    </li>
                                    <li class="item"><a href="/schedule">Schedule</a></li>
                                </ul>
                            </div>
                        </div>
                    </li>
                    <li class="search">
                        <form class="navbar-search" _lpchecked="1">
                        <input type="search" class="search-query typeahead" data-provide="typeahead" placeholder="Search"></form>
                        <a class="icon-search"></a></li>
                    <li class="admin mobile-dropdown"><a class="dropdown-toggle" data-toggle="dropdown"
                        href="#"><i class="icon-user"></i>Mark Campbell <span class="icon-angle-down"></span>
                    </a>
                        <div class="mobile-admin">
                            <div class="admin-wrapper">
                                <ul class="mobile-nav">
                                    <li><a href="http://www.w2bc.com">Profile</a></li>
                                    <li><a href="/createEmail">Create Mass Email</a></li>
                                    <li><a href="/adminDashboard">Admin Dashboard</a></li>
                                    <li><a href="/manageUsers">Manage Users</a></li>
                                    <li><a href="/manageEvents">Manage Streams</a></li>
                                    <li><a href="/manageAlbums">Manage Albums</a></li>
                                    <li><a href="/manageLocations">Manage Locations</a></li>
                                    <li><a href="/manageSchedules">Manage Schedules</a></li>
                                    <li><a href="/manageRoles">Manage Roles</a></li>
                                    <li><a href="/managePermissions">Manage Permissions</a></li>
                                    <li><a href="/managePermissionsRoles">Manage Permissions/Roles</a></li>
                                    <li><a href="/changepassword">Change Password</a></li>
                                    <li><a href="/logout">Log Out</a></li>
                                </ul>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
            <!--MOBILE-->
            <div class="navbar-inner visible-desktop">
                <ul class="nav">
                    <li><a href="http://www.w2bc.com">Home</a></li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Add
                        Profile<span class="icon-angle-down"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="http://www.w2bc.com">Twitter</a></li>
                            <li><a href="http://www.w2bc.com">Facebook</a></li>
                            <li><a href="http://www.w2bc.com">Google Plus</a></li>
                            <li><a href="http://www.w2bc.com">Instagram</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Create<span
                        class="icon-angle-down"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="/createStream">Create Stream</a></li>
                            <li><a href="/createAlbum">Create Album</a></li>
                            <li><a href="/createGroup">Create Group</a></li>
                        </ul>
                    </li>
                    <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">View<span
                        class="icon-angle-down"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="/viewStreams">View Streams</a></li>
                            <li><a href="/viewAlbums">View Albums</a></li>
                            <li><a href="/viewGroups">View Groups</a></li>
                        </ul>
                    </li>
                    <li class="item"><a href="/schedule">Schedule</a></li>
                    <li class="search">
                        <form class="navbar-search" _lpchecked="1">
                        <input type="search" class="search-query typeahead" data-provide="typeahead" placeholder="Search"></form>
                        <a class="icon-search"></a></li>
                    <li class="admin"><a class="dropdown-toggle" data-toggle="dropdown" href="#"><i class="icon-user">
                    </i>Mark Campbell <span class="icon-angle-down"></span></a>
                        <ul class="dropdown-menu">
                            <li><a href="/myProfile">Profile</a></li>
                            <li><a href="/createEmail">Create Mass Email</a></li>
                            <li><a href="/adminDashboard">Admin Dashboard</a></li>
                            <li><a href="/manageUsers">Manage Users</a></li>
                            <li><a href="/manageEvents">Manage Streams</a></li>
                            <li><a href="/manageAlbums">Manage Albums</a></li>
                            <li><a href="/manageLocations">Manage Locations</a></li>
                            <li><a href="/manageSchedules">Manage Schedules</a></li>
                            <li><a href="/manageRoles">Manage Roles</a></li>
                            <li><a href="/managePermissions">Manage Permissions</a></li>
                            <li><a href="/managePermissionsRoles">Manage Permissions/Roles</a></li>
                            <li><a href="/changepassword">Change Password</a></li>
                            <li><a href="/logout">Log Out</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <p>
            Work In Progress</p>

css3代码:

  .visible-phone
        {
            display: none !important;
        }
        .visible-tablet
        {
            display: none !important;
        }
        .hidden-desktop
        {
            display: none !important;
        }
        .visible-desktop
        {
            display: inherit !important;
        }
        @media (min-width: 768px) and (max-width: 979px)
        {
            .hidden-desktop
            {
                display: inherit !important;
            }
            .visible-desktop
            {
                display: none !important;
            }
            .navbar
            {
                overflow: visible;
            }
            .visible-tablet
            {
                display: inherit !important;
            }
            .hidden-tablet
            {
                display: none !important;
            }
        }
        @media (max-width: 767px)
        {
            .hidden-desktop
            {
                display: inherit !important;
            }
            .visible-desktop
            {
                display: none !important;
            }
            .navbar
            {
                overflow: visible;
            }
            .visible-phone
            {
                display: inherit !important;
            }
            .hidden-phone
            {
                display: none !important;
            }
        }
        html
        {
            background: #4e4955;
        }
        body
        {
            padding: 0;
            margin: 0;
            font-family: ‘Open Sans‘ , sans-serif;
            font-weight: 300;
            font-size: 1em;
        }
        *, *:after, *::before
        {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
        .navbar
        {
            position: relative;
            z-index: 99;
            width: 100%;
            min-width: 520px;
            height: 40px;
            max-height: 40px;
            background-color: #0b8c8c;
            background: -webkit-gradient(linear, left top, left bottom, from(#0b8c8c), to(#0b8787));
            background: -webkit-linear-gradient(top, #0b8c8c, #0b8787);
            background: -moz-linear-gradient(top, #0b8c8c, #0b8787);
            background: -ms-linear-gradient(top, #0b8c8c, #0b8787);
            background: -o-linear-gradient(top, #0b8c8c, #0b8787);
            border-bottom: 2px solid #0c9595;
            -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
            -moz-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
            box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.2);
        }
        .brand
        {
            float: left;
            padding: 0;
            margin: 0;
            padding: 1px 5px;
            display: inline-block;
        }
        .nav
        {
            padding: 0;
            margin: 0;
            display: block;
            text-align: left;
        }
        .nav li
        {
            position: relative;
            height: 40px;
            color: white;
            display: block;
            list-style: none;
            float: left;
            padding: 6px 15px;
        }
        .nav li a
        {
            color: white;
            text-decoration: none;
        }
        .nav li:first-child
        {
            border-left: 1px solid #097474;
        }
        .nav li:nth-last-child(3)
        {
            border-right: 1px solid #097474;
        }
        .nav li:hover, .active-drop
        {
            background: #0da4a4;
        }
        .nav li:hover ul.dropdown-menu, .active-drop ul.dropdown-menu
        {
            padding: 0;
            margin: 0;
            border: none;
            background: #0b8c8c;
            position: absolute;
            z-index: 98;
            top: 40px;
            right: 0;
            display: block;
            width: 250px;
        }
        .nav li:hover ul.dropdown-menu li, .active-drop ul.dropdown-menu li
        {
            width: 100%;
            line-height: 20px;
            border: none;
            margin: 0;
        }
        .nav li.admin
        {
            float: right;
        }
        .nav li.search
        {
            width: 45px;
            border-right: 1px solid #097474;
            overflow: hidden;
            -webkit-transition: all 0.5s ease-in-out;
            -moz-transition: all 0.5s ease-in-out;
            -ms-transition: all 0.5s ease-in-out;
            -o-transition: all 0.5s ease-in-out;
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden; /* Chrome and Safari */
            -moz-backface-visibility: hidden; /* Firefox */
            -ms-backface-visibility: hidden; /* Internet Explorer */
        }
        .nav li.search:hover, .active-search
        {
            width: 250px;
        }
        .navbar-search
        {
            position: absolute;
            top: 5px;
            left: 45px;
        }
        .navbar-search input
        {
            font-weight: 300;
            font-size: 1em;
            border: none;
            background: #075d5d;
            color: white;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            -moz-background-clip: padding;
            -webkit-background-clip: padding-box;
            background-clip: padding-box;
        }
        .icon-angle-down
        {
            padding-left: 3px;
        }
        ul.dropdown-menu
        {
            display: none;
        }
        .mobile-dropdown
        {
            border-right: 1px solid #097474;
        }
        .mobile-dropdown:hover .mobile-menu
        {
            -webkit-transform: translate(0px, 0);
            -moz-transform: translate(0px, 0);
            -ms-transform: translate(0px, 0);
            -o-transform: translate(0px, 0);
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden; /* Chrome and Safari */
            -moz-backface-visibility: hidden; /* Firefox */
            -ms-backface-visibility: hidden; /* Internet Explorer */
        }
        .mobile-dropdown:hover .mobile-admin
        {
            -webkit-transform: translate(0px, 0);
            -moz-transform: translate(0px, 0);
            -ms-transform: translate(0px, 0);
            -o-transform: translate(0px, 0);
            backface-visibility: hidden;
            -webkit-backface-visibility: hidden; /* Chrome and Safari */
            -moz-backface-visibility: hidden; /* Firefox */
            -ms-backface-visibility: hidden; /* Internet Explorer */
        }
        .mobile-admin
        {
            position: fixed;
            top: 40px;
            bottom: 0;
            right: 0px;
            display: block;
            width: 280px;
            background: #0b8c8c;
            overflow: hidden;
            -webkit-transform: translate(330px, 0);
            -moz-transform: translate(330px, 0);
            -ms-transform: translate(330px, 0);
            -o-transform: translate(330px, 0);
            -webkit-transition: all 0.5s ease-in-out;
            -moz-transition: all 0.5s ease-in-out;
            -ms-transition: all 0.5s ease-in-out;
            -o-transition: all 0.5s ease-in-out;
        }
        .mobile-menu
        {
            position: fixed;
            top: 40px;
            bottom: 0;
            left: 0px;
            display: block;
            width: 300px;
            background: #0b8c8c;
            overflow: hidden;
            -webkit-transform: translate(-330px, 0);
            -moz-transform: translate(-330px, 0);
            -ms-transform: translate(-330px, 0);
            -o-transform: translate(-330px, 0);
            -webkit-transition: all 0.5s ease-in-out;
            -moz-transition: all 0.5s ease-in-out;
            -ms-transition: all 0.5s ease-in-out;
            -o-transition: all 0.5s ease-in-out;
        }
        .admin-wrapper, .menu-wrapper
        {
            overflow-y: scroll;
            width: 390px;
            height: 100%;
        }
        .mobile-admin ul.mobile-nav, .mobile-menu ul.mobile-nav
        {
            position: relative;
            right: 40px;
            top: 0;
            font-size: 1.2em;
            font-weight: 400;
            width: 100%;
            border-left: 1px solid #0c9f9f;
        }
        .mobile-admin ul.mobile-nav li, .mobile-menu ul.mobile-nav li
        {
            border: none;
            padding-bottom: 0px;
            border-top: 1px solid #0c9f9f;
            width: 100%;
            position: relative;
            height: 100%;
        }
        .mobile-menu ul.mobile-nav li:hover
        {
            background: #0c9595;
        }
        .mobile-menu ul.mobile-nav li:hover ul.dropdown-menu
        {
            padding: 0;
            margin: 0;
            border: none;
            background: #0b8c8c;
            position: relative;
            z-index: 98;
            top: 0;
            right: 15px;
            display: block;
            width: 100%;
        }
        .mobile-menu ul.mobile-nav li:hover ul.dropdown-menu li
        {
            width: 100%;
            line-height: inherit;
            border-top: 1px solid #0c9f9f;
            margin: 0;
        }
        .mobile-menu ul.mobile-nav li ul.dropdown-menu
        {
            display: block;
            overflow: hidden;
            height: 100%;
            padding: 0;
            margin: 0;
            border: none;
            background: #0c9595;
            position: relative;
            z-index: 98;
            top: 0;
            right: 15px;
            width: 100%;
        }
        .mobile-menu ul.mobile-nav li ul.dropdown-menu li
        {
            font-size: .9em;
            font-weight: 300;
            display: inline-block;
            width: 100%;
            line-height: inherit;
            border-top: 1px solid #0c9f9f;
            margin: 0;
        }

注:本文爱编程原创文章,转载请注明原文地址:http://www.w2bc.com/Article/9521

时间: 2024-09-27 01:20:32

一款纯css3实现的响应式导航的相关文章

纯css3开发的响应式设计动画菜单(支持ie8)

这是一个响应式设计的菜单.单击列表图标,当你显示屏大小可以完全水平放下所有菜单项时,菜单水平显示(如图1).当你的显示屏不能水平放置所有菜单项时,菜单垂直显示(如图2). 而且显示的时候是以动画的型式显示.效果相当的好. 点击这里在线预览 下面贴出实现这功能的源代码,这是一个纯用css3实现的菜单 html代码: <div class="container"> <!--[if lte IE 8]> <style> .iconicmenu > l

一款纯css3实现的竖形二级导航的实例教程

之前为大家分享了好多导航菜单.今天给大家带来一款纯css3实现的竖形二级导航.这款导航菜单可以是无限级.一起看下效果图: 实现的代码. html代码: XML/HTML Code复制内容到剪贴板 <div style="width: 700px; margin: auto;"> <div class="W1-h16"> <ul> <li class="has-sub"><a href=&quo

纯css3实现的竖形二级导航

之前为大家分享了好多导航菜单.今天给大家带来一款纯css3实现的竖形二级导航.这款导航菜单可以是无限级.一起看下效果图: 在线预览   源码下载 实现的代码. html代码: <div style="width: 700px; margin: auto;"> <div class="W1-h16"> <ul> <li class="has-sub"><a href="#"&

CSS3+Js制作的一款响应式导航条

今天制作了一个响应式导航条,能够自动随着不同的屏幕分辨率或浏览器窗口大小的不同而改变导航条的样式,这里主要用到的就是CSS3的Media Query.具体可以查看浅谈响应式布局这篇文章,这里就不花费大量的篇幅介绍了,主要看一下这个导航条该怎么做. 另外需要提到的是,ie6-ie8是不支持CSS3的Media Query的,因此对于ie6-ie8我们需要特殊处理,就让他们保持默认样式,这对于布局及样式上都要考虑到这一点. 首先看一下布局这一块,html代码如下: 1 2 3 4 5 6 7 8 9

一款纯css3实现的条纹加载条

之前为大家带来了很多加载动画. 基于prefixfree.js的进度加载条 ,基于jquery带百分比的响应式进度加载条.今天给大家分享一款纯css3实现的条纹加载条.带有响应式的效果.效果图如下 : 在线预览   源码下载 实现的代码. html代码: <div class="container"> <div class="warning"> </div> </div> css3代码: .warning { posi

15款帮助你实现响应式导航的 jQuery 插件

对于我们大多数人来说,建立一个负责任的布局中最困难的方面是规划和导航的实现.由于没有真正经得起考验的通用解决方案,您可以使用的菜单设计风格将取决于正在建设的网站类型. 无论你正在建设什么类型的网站,在这篇文章中我们将向推荐一批制作响应式导航的 jQuery 插件,为您提供方便快速的解决方案. 您可能感兴趣的相关文章 Web 开发中很实用的10个效果[源码下载] 精心挑选的优秀jQuery Ajax分页插件和教程 12个让人惊叹的的创意的 404 错误页面设计 让网站动起来!12款优秀的 jQue

如何利用CSS3与jQuery实现响应式导航

在前端开发中,我们常常需要利用CSS3 media queries + jQuery来实现响应式导航,那它的具体实现步骤和方法到底是怎样的呢?一起来看看吧,希望可以帮助大家更好地学习CSS3. 目的: 实现一个响应式导航,当屏幕宽度大于700px时,效果如下: 当屏幕宽度小于700px时,导航变成一个小按钮,点击之后有一个菜单慢慢拉下来: 思路: 1.为了之后在菜单上绑定事件,并且不向DOM中添加多余的节点,在大屏幕中出现的导航和小屏幕中的下拉导航必须是一个. 所以我选择了将导航绝对定位. 2.

一款纯css3实现的动画加载导航

之前为大家介绍了好几款导航菜单,今天为给大家再带来一款纯css3实现的动画加载导航.该导航出现的时候以动画的形式出现.效果图如下: 在线预览   源码下载 实现的代码. html代码: <ul class="main-menu"> <li class="main-menu-item active"><a href="#">Home</a></li><li class="m

一款纯css3实现的数字统计游戏

今天给大家分享一款纯css3实现的数字统计游戏.这款游戏的规则的是将所有的数字相加等于72.这款游戏的数字按钮做得很美观,需要的时候可以借用下.一起看下效果图: 在线预览   源码下载 实现的代码. html代码: <h1> CSS Counter Game</h1> <section> <h2> Pick the numbers that add up to 72:</h1> <input id="a" type=&q