教你如何做一个漂亮的下拉菜单导航.doc_第1页
教你如何做一个漂亮的下拉菜单导航.doc_第2页
教你如何做一个漂亮的下拉菜单导航.doc_第3页
教你如何做一个漂亮的下拉菜单导航.doc_第4页
教你如何做一个漂亮的下拉菜单导航.doc_第5页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

教你如何做一个漂亮的下拉菜单导航标签:惠州网站建设 下拉菜单在本教程中我们将纯CSS 3代码纯制作导航菜单。 第一步 HTML 我们将创建一个列表项,并为每个菜单链接的锚标记无序列表。若要创建子菜单添加另一个无序列表内的名单。 网站建设 网站制作 网站优化 Documents Messages Sign Out Uploads Videos Documents 第二步 菜单布局 我们先把菜单中的所有元素移除。然后,我们将增加一个固定的宽度和高度,圆角有CSS3梯度的菜单。为了让链接水平对齐,我们让列表左浮动。我们还需要设置它为相对位置,因为我们需要对齐子菜单。.menu,.menu ul,.menu li,.menu a margin: 0; padding: 0; border: none; outline: none;.menu height: 40px; width: 505px; background: #4c4e5a; background: -webkit-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%); background: -moz-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%); background: -o-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%); background: -ms-linear-gradient(top, #4c4e5a 0%,#2c2d33 100%); background: linear-gradient(top, #4c4e5a 0%,#2c2d33 100%); -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px;.menu li position: relative; list-style: none; float: left; display: block; height: 40px;我们将暂时隐藏子菜单,以更容易的定义第一级菜单。.menu ul display: none; 第三步 菜单链接 首先给菜单加一些基本的CSS样式如字体,颜色等,然后我们将添加一个黑暗的文字阴影和过渡色来创建一个悬停状态时颜色变化平滑的效果。加一个左边框和右边框来做链接分隔,去掉第一个和最后一个项的左边框和右边框。悬停状态效果,只需要改变字体颜色。 .menu li a display: block; padding: 0 14px; margin: 6px 0; line-height: 28px; text-decoration: none; border-left: 1px solid #393942; border-right: 1px solid #4f5058; font-family: Helvetica, Arial, sans-serif; font-weight: bold; font-size: 13px; color: #f3f3f3; text-shadow: 1px 1px 1px rgba(0,0,0,.6); -webkit-transition: color .2s ease-in-out; -moz-transition: color .2s ease-in-out; -o-transition: color .2s ease-in-out; -ms-transition: color .2s ease-in-out; transition: color .2s ease-in-out;.menu li:first-child a border-left: none; .menu li:last-child a border-right: none; .menu li:hover a color: #8fde62; 第四步 子菜单 首先,我们先删除第二步加的这行代码。.menu ul display: none; 现在,我们给子菜单定义样式。给子菜单定位离顶部40px,左侧0px,差加底部圆角。我们设置不透视度为0,悬停状态为1来做一个淡入淡出的效果。对于切片上下切换的效果,我们需要设置列表的高度0px时是隐藏36px悬停状态。 .menu ul position: absolute; top: 40px; left: 0; opacity: 0; background: #1f2024; -webkit-border-radius: 0 0 5px 5px; -moz-border-radius: 0 0 5px 5px; border-radius: 0 0 5px 5px; -webkit-transition: opacity .25s ease .1s; -moz-transition: opacity .25s ease .1s; -o-transition: opacity .25s ease .1s; -ms-transition: opacity .25s ease .1s; transition: opacity .25s ease .1s;.menu li:hover ul opacity: 1; .menu ul li height: 0; overflow: hidden; padding: 0; -webkit-transition: height .25s ease .1s; -moz-transition: height .25s ease .1s; -o-transition: height .25s ease .1s; -ms-transition: height .25s ease .1s; transition: height .25s ease .1s;.menu li:hover ul li height: 36px; overflow: visible; padding: 0;我们将设置子菜单链接的宽度为100px。.menu ul li a width: 100px; padding: 4px 0 4px 40px; margin: 0; border: none; border-bottom: 1px solid #353539;.menu ul li:last-child a border: none; 现在,我们只需要添加图标和子菜单链接来完成它。要做到这点,我们只要自定义一个类,差加背景图片。.menu a.documents background: url(./img/docs.png) no-repeat 6px cen

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论