导航菜单其实是没有什么可说的,制作方法到处可见,今天这个案例本来不只是一个导

航,还有一个搜索表单的,可是为了偷懒,把搜索表单部分去掉了,就变成了一个CSS3

制作的下拉菜单。在这个导航中主要两点,一个是渐变运用,另一个就是box-shodow

制作的立体效果。

HTML 结构:

<ul id="nav">
  <li><a href="#">Home</a></li>
  <li>
    <a href="#">Portfolio</a>
    <ul class="sub-menu">
      <li><a href="#">Identity</a></li>
      <li><a href="#">Print</a></li>
      <li><a href="#">Online</a></li>
    </ul>
  </li>
  <li><a href="#">About</a></li>
  <li><a href="#">Contact</a></li>
  <li><a href="#">W3cplus</a></li>
</ul>

  CSS代码

*{
  margin: 0;
  padding: 0;
}
body {
  padding: 50px;
  background: url(data:image/j...);
  font-family: 'Jockey One', sans-serif;
  color: #fff;
}
a {
  color: rgb(1, 124, 185);
  text-decoration: none;
}
li {
  list-style: none outside none;
}
#nav:after,
#nav:before {
  content:"";
  display: table;
}
#nav:after {
  clear:both;
  overflow: hidden;
}
#nav {
  zoom: 1;
  margin: 50px auto;
  width: 530px;
}
#nav > li{
  float: left;
  display: inline;
  border-right: 1px solid #848d95;
  border-left: 1px solid #e3e8ec;
  box-shadow: 0 1px 0 rgba(84,95,109,0.75),0 2px 0 rgba(84,95,109,0.75),0 3px 0 rgba(84,95,109,0.75);
  position: relative;
  background-color: #c5cfd8; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2M1Y2ZkOCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM5Y2E4YjEiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #c5cfd8 0%, #9ca8b1 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#c5cfd8), color-stop(100%,#9ca8b1)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #c5cfd8 0%,#9ca8b1 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #c5cfd8 0%,#9ca8b1 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#c5cfd8', endColorstr='#9ca8b1',GradientType=0 ); /* IE6-8 */
  -webkit-transition: all 0.25s ease-in .0038s;
  -moz-transition: all 0.25s ease-in .0038s;
  -o-transition: all 0.25s ease-in .0038s;
  transition: all 0.25s ease-in .0038s;
}
#nav li:first-child {
  border-left: none;
  border-radius:  5px 0 0 5px;
}
#nav li:last-child {
  border-radius: 0 5px 5px 0;
  border-right: none;
}
#nav li:last-child::after {
  display: none;
}
#nav .sub-menu {
  position: absolute;
  right: 0;
  left: -1px;
  top: 100%;
  border-radius: 0 0 5px 5px;
  box-shadow: 0 1px 0 rgba(84,95,109,0.75),0 2px 0 rgba(84,95,109,0.75),0 3px 0 rgba(84,95,109,0.75);
  background-color: #d9e0e5; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2Q5ZTBlNSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNjNWNkZDMiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #d9e0e5 0%, #c5cdd3 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#d9e0e5), color-stop(100%,#c5cdd3)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #d9e0e5 0%,#c5cdd3 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #d9e0e5 0%,#c5cdd3 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d9e0e5', endColorstr='#c5cdd3',GradientType=0 ); /* IE6-8 */
  display: none;
}
#nav > li:hover {
  background-color: #d8dfe4; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIxJSIgc3RvcC1jb2xvcj0iI2Q4ZGZlNCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNkNWRlZTQiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);  background-image: -moz-linear-gradient(top,  #d8dfe4 1%, #d5dee4 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#d8dfe4), color-stop(100%,#d5dee4)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #d8dfe4 1%,#d5dee4 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #d8dfe4 1%,#d5dee4 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#d8dfe4', endColorstr='#d5dee4',GradientType=0 ); /* IE6-8 */
  position: relative;
  top: 3px;
  border-right-color: #848d95;
  box-shadow: -1px 0 0 #848d95;
  color: #2281cd;
}
#nav li:hover > ul {
  display: block;
}
#nav a {
  display: block;
  float: left;
  padding: 15px 30px;
  font-size: 16px;
  color: #2d2f38;
  text-shadow: 0 1px 0 rgba(225,232,235,0.75);
  -webkit-transition: all 0.25s ease-in .0038s;
  -moz-transition: all 0.25s ease-in .0038s;
  -o-transition: all 0.25s ease-in .0038s;
  transition: all 0.25s ease-in .0038s;
}
#nav a:hover {
  color: #2281cd;
}
#nav .sub-menu a {
  color: #2d2f38;
  font-size: 14px;
  padding: 10px 30px;
  float: none;
}
#nav .sub-menu a:hover {
  background-color: #a4b0ba; /* Old browsers */
  /* IE9 SVG, needs conditional override of 'filter' to 'none' */
  background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2E0YjBiYSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjQlIiBzdG9wLWNvbG9yPSIjZDVkZWU0IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iI2I1YzBjOSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);  background-image: -moz-linear-gradient(top,  #a4b0ba 0%, #d5dee4 4%, #b5c0c9 100%); /* FF3.6+ */
  background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#a4b0ba), color-stop(4%,#d5dee4), color-stop(100%,#b5c0c9)); /* Chrome,Safari4+ */
  background-image: -webkit-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* Chrome10+,Safari5.1+ */
  background-image: -o-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* Opera 11.10+ */
  background-image: -ms-linear-gradient(top,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* IE10+ */
  background-image: linear-gradient(to bottom,  #a4b0ba 0%,#d5dee4 4%,#b5c0c9 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#a4b0ba', endColorstr='#b5c0c9',GradientType=0 ); /* IE6-8 */
  box-shadow: 0 1px 0 rgba(255,255,255,0.75),inset 0 2px 6px rgba(69,78,90,0.15);
}
#nav .sub-menu li:last-child a:hover {
  border-radius: 0 0 5px 5px;
}

  

出处:

http://www.w3cplus.com/demo/create-nav-menu-with-css3.html

CSS3制作下拉菜单的更多相关文章

  1. Html5+Css3制作下拉菜单的三种方式

    一.渐变式改变ol的高度 1.外部为ul标签,在每个li里嵌套一个ol列表2.设置外部li左浮动,内部ol标签绝对定位,外部li标签相对定位3.设置ol的高为0,溢出隐藏4.外部li标签:hover ...

  2. 纯css3圆角下拉菜单 都没敢用js

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. jQuery+Superfish制作下拉菜单

    superfish制作下拉菜单真的很方便而好很好用,而且还可以通过Superfish提供的参数来控制下拉菜单的不同效果,而且他没有层级限制,换句话说可以通过Superfish来写你想要的层级菜单. 官 ...

  4. 制作下拉菜单(PopupList)

    怎样判断是否应当使用下拉菜单 下拉菜单,就是将一系列的选项隐藏,通过单击某一个控件将会弹出一个包含这些选项的列表,在其中选择想要的选项.这样做不但可以节省屏幕空间,也可以让用户在进行选择时更加方便快捷 ...

  5. html 布局;css3+jq 下拉菜单;table分页动态添加行;html5本地存储;简单易用的html框架

    简单好用的html框架,预览图见最后: 源码: 1.页面布局使用table: table 嵌套 +iframe 布局: 2.下拉菜单为jq+css3 动画; css input 无边框,select下 ...

  6. css用hover制作下拉菜单

    首先我们的需求就是 制作一个鼠标移动到某个区域就会有下拉菜单的弹出,这样会有更多的子类内容,示例代码如下: <!DOCTYPE html> <html lang="en&q ...

  7. 小米网css3导航下拉菜单代码

    效果:http://hovertree.com/texiao/css3/19/ 代码如下: <!doctype html> <!-- W3C规范 --> <html la ...

  8. vue + element-ui 制作下拉菜单(可配置路由、可根据路由高亮list、可刷新自动展开定位路由)

    本篇文章分享一篇关于 vue制作可路由切换组件.可刷新根据路由定位导航(自动展开).可根据路由高亮对应导航选项 一.实现的功能如下: 1.可折叠导航面板 2.点击导航路由不同组件           ...

  9. 使用PopupContainerEdit和PopupContainerControl制作下拉菜单树小记

    转自:http://jlcon.iteye.com/blog/898210 首先拖动一个PopupContainerEdit控件和PopupContainerControl控件到界面上,在PopupC ...

随机推荐

  1. Linux 系统下原版 texlive 2016 的安装与配置

    尽管大部分常见的linux系统的包管理器内都会包含texlive,然而最好还是安装TUG发布的原版texlive.这是由于:1,软件仓库内的texlive通常版本较陈旧:2,由于版权因素一些tex宏包 ...

  2. MATLAB的基本元素

    MALTAB程序的基本数据单元是数组,MATLAB 的变量名必须以字母开头,后面可以跟字母,数字和下划线(_).只有前31个字符是有效的:如果超过了31 个字符,基余的字符将被忽略.如果声明两个变量, ...

  3. 对css float 浮动的学习心得

    css float浮动详解 @(css float)[hasLayout|clear float|妙瞳] css float的定义和用法 float 属性定义元素在哪个方向浮动.以往这个属性总应用于图 ...

  4. oracle添加表字段跟修改表字段属性

    添加字段 alter table mid_contactinfo add(status varchar(20),createdate varchar(50),modifydate varchar(50 ...

  5. java poi出excel换行问题

    POI操作excel实现换行问题. package jp.co.misumi.mdm.batch.common.jobrunner; import java.io.FileInputStream; i ...

  6. mysql关键字讲解(join 、order by、group by、having、distinct)

    1.join     1.1 OUTER JOIN:想要包含右侧表中的所有行,以及左侧表中有匹配记录的行.        1.11 Mysql中有左连接(left join):            ...

  7. vs2010开发android的准备工作

    安装 Mono for Android for Visual Studio 2010 需要下面4个步骤: 安装 JDK 安装 Android SDK 配置模拟器 安装 Mono for Android ...

  8. mysql net连接读取结果为乱码 Incorrect string value

    在mysql直接查询中文正常,通过连接到mysql读取中文内容为乱码.同时插入中文内容也失败提示 Incorrect string value: '\xBC\xA4\xB7\xA2\xBF\xB4.. ...

  9. Java实战之02Hibernate-05检索策略、检索方式

    十一.Hibernate的检索策略 1.概述: 查询的时机:什么时候去查? /** * 一张表的检索策略我们称之为: * 类级别的检索策略. * 注意:只要是说类级别的检索策略,就一定不涉及关联对象. ...

  10. 12_CXF入门

    [CXF] Apache CXF = Celtix + Xfire,开始叫 Apache CeltiXfire,后来更名为 Apache CXF 了,以下简称为 CXF.Apache CXF 是一个开 ...