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


Posted in HTML / CSS onOctober 31, 2014

之前为大家介绍了好几款响应式导航。今天再给大家带来一款纯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="https://3water.com">Home</a></li>
<li class="dropdown"><a href="#" _fcksavedurl=""#"" _fcksavedurl=""#"" _fcksavedurl=""#"" 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="https://3water.com">Profile</a></li>
<li><a href="/createEmail">Create _fcksavedurl=""/createEmail">Create" _fcksavedurl=""/createEmail">Create" _fcksavedurl=""/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="https://3water.com">Home</a></li>
<li class="dropdown"><a href="#" _fcksavedurl=""#"" _fcksavedurl=""#"" _fcksavedurl=""#"" class="dropdown-toggle" data-toggle="dropdown">Add
Profile<span class="icon-angle-down"></span></a>
<ul class="dropdown-menu">
<li><a href="https://3water.com">Twitter</a></li>
<li><a href="https://3water.com">Facebook</a></li>
<li><a href="https://3water.com">Google Plus</a></li>
<li><a href="https://3water.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;
}
HTML / CSS 相关文章推荐
CSS3+js实现简单的时钟特效
Mar 18 HTML / CSS
初探CSS3中的calc()功能
Jul 14 HTML / CSS
老生常谈CSS中的长度单位
Jun 27 HTML / CSS
css3的动画特效之动画序列(animation)
Dec 22 HTML / CSS
html5 video标签屏蔽右键视频另存为的js代码
Nov 12 HTML / CSS
使用phonegap创建联系人的实现方法
Mar 30 HTML / CSS
简述Html5 IphoneX 适配方法
Feb 08 HTML / CSS
浅谈Html5多线程开发之WebWorkers
May 02 HTML / CSS
html5中嵌入视频自动播放的问题解决
May 25 HTML / CSS
浅析HTML5 Landmark
Sep 11 HTML / CSS
使用CSS实现一个搜索引擎的原理解析
Sep 25 HTML / CSS
基于HTML十秒做出淘宝页面
Oct 24 HTML / CSS
CSS3提交意见输入框样式代码
Oct 30 #HTML / CSS
css3实例教程 一款纯css3实现的环形导航菜单
Oct 20 #HTML / CSS
在HTML5中如何使用CSS建立不可选的文字
Oct 17 #HTML / CSS
布局和排版教程 纯css3实现图片三角形排列
Oct 17 #HTML / CSS
IE浏览器单独写CSS样式的几种方法
Oct 14 #HTML / CSS
CSS3 重置iphone浏览器按钮input,select等表单元素的默认样式
Oct 11 #HTML / CSS
css3 图片圆形显示 如何CSS将正方形图片显示为圆形图片布局
Oct 10 #HTML / CSS
You might like
[转帖]PHP世纪万年历
2006/12/06 PHP
php使用GD创建保持宽高比缩略图的方法
2015/04/17 PHP
PHP使用Pthread实现的多线程操作实例
2015/11/14 PHP
js导航栏单击事件背景变换示例代码
2014/01/13 Javascript
JavaScript原生对象之Date对象的属性和方法详解
2015/03/13 Javascript
浅谈jquery事件处理
2015/04/24 Javascript
使用AJAX实现Web页面进度条的实例分享
2016/05/06 Javascript
jQuery插件Echarts实现的双轴图效果示例【附demo源码下载】
2017/03/04 Javascript
React-Native做一个文本输入框组件的实现代码
2017/08/10 Javascript
Node.js中DNS模块学习总结
2018/02/28 Javascript
详解vue项目中使用token的身份验证的简单实践
2019/03/08 Javascript
jquery css实现流程进度条
2020/03/26 jQuery
vue实现五子棋游戏
2020/05/28 Javascript
详解Vue 数据更新了但页面没有更新的 7 种情况汇总及延伸总结
2020/05/28 Javascript
vue监听滚动事件的方法
2020/12/21 Vue.js
vue中配置scss全局变量的步骤
2020/12/28 Vue.js
[01:12:35]Spirit vs Navi Supermajor小组赛 A组败者组第一轮 BO3 第二场 6.2
2018/06/03 DOTA
Python中操作MySQL入门实例
2015/02/08 Python
Python保存MongoDB上的文件到本地的方法
2016/03/16 Python
Python中的with语句与上下文管理器学习总结
2016/06/28 Python
解决Django模板无法使用perms变量问题的方法
2017/09/10 Python
运行django项目指定IP和端口的方法
2018/05/14 Python
pandas DataFrame 根据多列的值做判断,生成新的列值实例
2018/05/18 Python
Python Image模块基本图像处理操作小结
2019/04/13 Python
pytorch AvgPool2d函数使用详解
2020/01/03 Python
在Pytorch中使用Mask R-CNN进行实例分割操作
2020/06/24 Python
Pandas中两个dataframe的交集和差集的示例代码
2020/12/13 Python
HTML5实现页面切换激活的PageVisibility API使用初探
2016/05/13 HTML / CSS
计算机专业自我鉴定
2013/10/15 职场文书
考试作弊被抓检讨书
2014/01/10 职场文书
幼儿园数学教学反思
2014/02/02 职场文书
数控专业大学毕业生职业规划范文
2014/02/06 职场文书
12月红领巾广播稿
2014/02/13 职场文书
社区禁毒工作方案
2014/06/02 职场文书
水电工程师岗位职责
2015/02/13 职场文书
2015年仓管员工作总结
2015/04/21 职场文书