这是一个响应式设计的菜单。单击列表图标,当你显示屏大小可以完全水平放下所有菜单项时,菜单水平显示(如图1)。当你的显示屏不能水平放置所有菜单项时,菜单垂直显示(如图2)。 而且显示的时候是以动画的型式显示。效果相当的好。

点击这里在线预览

下面贴出实现这功能的源代码,这是一个纯用css3实现的菜单

html代码:

 <div class="container">
<!--[if lte IE 8]>
<style> .iconicmenu > label{
border-width: 7px;
background: #eee;
} .iconicmenu:hover ul{
left: 8px; /* show menu onmouseover in IE8 and below */
} </style>
<![endif]-->
<div class="iconicmenu">
<input type="checkbox" id="togglebox" />
<ul>
<li><a targe="_blank" href="http://www.w2bc.com/Shili/css3%E8%8F%9C%E5%8D%95">Home</a></li>
<li><a targe="_blank" href="http://www.w2bc.com/Shili/css3%E8%8F%9C%E5%8D%95">DHTML</a></li>
<li><a targe="_blank" href="http://www.w2bc.com/Shili/css3%E8%8F%9C%E5%8D%95">CSS Library</a></li>
<li><a targe="_blank" href="http://www.w2bc.com/Shili/css3%E8%8F%9C%E5%8D%95">CSS Gallery</a></li>
<li><a targe="_blank" href="http://www.w2bc.com/Shili/css3%E8%8F%9C%E5%8D%95">JavaScript</a></li>
<li>
<label for="togglebox">
</label>
</li>
</ul>
<label class="toggler" for="togglebox">
Menu</label>
</div>
</div>

这里加入了兼容ie8的hack 。

css代码:

        body
{
padding:; margin:;
}
.container
{
width:600px; margin:auto;
}
.iconicmenu {
position: relative;
height: 45px;
overflow: hidden;
} .iconicmenu, .iconicmenu * {
-moz-box-sizing: border-box;
box-sizing: border-box;
} .iconicmenu input[type="checkbox"] { /* checkbox used to toggle menu state */
position: absolute;
left:;
top:;
opacity:;
} .iconicmenu > label { /* Main label icon to toggle menu state */
z-index:;
display: block;
position: absolute;
width: 40px;
height: 40px;
float: left;
top:;
left:;
background: white;
text-indent: -1000000px;
border: 6px solid black; /* border color */
border-width: 6px 0;
cursor: pointer;
-moz-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
transition: all 0.3s ease-in; /* transition for flipping label */
} .iconicmenu > label::after { /* inner stripes inside label */
content: "";
display: block;
position: absolute;
width: 100%;
height: 18%;
top: 19%;
left:;
border: 6px solid black; /* border color */
border-width: 6px 0;
-moz-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
transition: all 0.3s ease-in; /* transition for flipping label */
} .iconicmenu ul { /* UL menu inside container */
margin:;
padding:;
position: absolute;
margin-left: 40px;
background: #eee;
left: -100%; /* hide menu intially */
height: 40px; /* height of menu */
font: bold 14px Verdana;
text-align: center;
list-style: none;
opacity:;
-moz-border-radius: 0 5px 5px 0;
-webkit-border-radius: 0 5px 5px 0;
border-radius: 0 5px 5px 0;
-moz-perspective: 10000px;
perspective: 10000px;
-moz-transition: all 0.5s ease-in;
-webkit-transition: all 0.5s ease-in;
transition: all 0.5s ease-in; /* transition for animating UL in and out */
} .iconicmenu li {
display: inline;
margin:;
padding:;
} .iconicmenu ul label { /* label button inside UL to close menu */
cursor: pointer;
position: relative;
height: 100%;
text-align: center;
} .iconicmenu ul label::after { /* label button x */
content: "x";
display: inline-block;
line-height: 14px;
color: white;
-moz-border-radius: 50px;
-webkit-border-radius: 50px;
border-radius: 50px;
width: 20px;
height: 20px;
background: black;
font-size: 18px;
margin: 5px;
margin-top: 10px;
-moz-transition: all 0.3s ease-in;
-webkit-transition: all 0.3s ease-in;
transition: all 0.3s ease-in;
} .iconicmenu input[type="checkbox"]:checked ~ label, .iconicmenu ul label:hover::after {
-moz-transform: rotatey(180deg);
-ms-transform: rotatey(180deg);
-webkit-transform: rotatey(180deg);
transform: rotatey(180deg); /* flip labels vertically onMouseover */
} .iconicmenu > label:hover, .iconicmenu > label:hover::after, .iconicmenu input[type="checkbox"]:checked ~ label, .iconicmenu input[type="checkbox"]:checked ~ label::after {
border-color: darkred; /* highlight color of main menu label onMouseover */
} .iconicmenu input[type="checkbox"]:checked ~ ul {
left: 8px; /* Animate menu into view */
opacity:;
-moz-box-shadow: 1px 1px 5px gray;
-webkit-box-shadow: 1px 1px 5px gray;
box-shadow: 1px 1px 5px gray;
} .iconicmenu li a {
display: block;
float: left;
text-align: center;
text-decoration: none;
color: black;
margin:;
padding: 10px;
padding-right: 15px;
height: 100%;
} .iconicmenu li a:hover {
background: black;
color: white;
} /* ----------------------------- CSS Media Queries ----------------------------- */ /*
These rules control which portions of the menu gets shown when the screen size is below a certain width.
By default 2 stages are defined depending on browser screen width.
*/ @media screen and (max-width: 580px) { /* Hide toggle icon when menu is already open (increases usable menu space by 40px) */
.iconicmenu input[type="checkbox"]:checked ~ label {
display: none;
}
.iconicmenu input[type="checkbox"]:checked ~ ul {
margin-left:;
}
} @media screen and (max-width: 560px) { /* Convert horizontal menu to vertical drop down instead (friendly across all screen sizes) */
.iconicmenu {
overflow: visible;
}
.iconicmenu ul {
height: auto;
}
.iconicmenu ul li {
min-width: 200px;;
display: block;
}
.iconicmenu ul li a {
float: none;;
text-align: left;
}
}

转载请注明原文地址:

纯css3开发的响应式设计动画菜单(支持ie8)的更多相关文章

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

    之前为大家介绍了好几款响应式导航.今天再给大家带来一款纯css3实现的响应式导航.这款导航还有个响应式的搜索框.废话少说,直接上图: 在线预览   源码下载 实现的代码. html代码: <di ...

  2. html5、css3及响应式设计入门

    一.响应式设计的定义 将三种已有的开发技巧(弹性网格布局.弹性图片.媒体和媒体查询)整合起来,命名为响应式网页设计.真正的响应式设计方法不仅仅只是根据视口大小改变网页布局.相反,它是要从整体上颠覆我们 ...

  3. HTML5、CSS3响应式设计——笔记

    1.1.响应式网页设计 响应式网页设计(RWD,Responsive Web Design)这个术语,由伊桑·马科特(EthanMarcotte)提出.他在A List Apart 发表了一篇开创性的 ...

  4. CSS3知识点整理(五)----响应式设计及其他属性

    介绍Media Queries与Responsive设计以及外轮廓属性.resize属性.CSS3生成内容等 学会如何使用CSS3中的Media Queries模块来让一个页面适应不同的终端(或屏幕尺 ...

  5. Windows10 UWP开发 - 响应式设计

      Windows10 UWP开发 - 响应式设计 本篇随笔与大家简单讨论一下在开发适配不同分辨率.宽高比的Windows10 Universal App布局时的可行方式与小技巧.经验均从实践中总结, ...

  6. HTML5实践 -- 使用CSS3 Media Queries实现响应式设计

    CSS3 Media用法介绍:http://www.w3cplus.com/content/css3-media-queries 转载请注明原创地址:http://www.cnblogs.com/so ...

  7. Windows 10 响应式设计和设备友好的开发

    使用Effective pixels有效像素设计UI 什么是缩放像素和Effective有效像素: 当你的应用程序运行在Windows的设备,系统用一个算法控制的规范,字体,和其他UI元素显示在屏幕上 ...

  8. 一款由css3和jquery实现的响应式设计导航

    2014年响应式设计成为设计主流.今天要给大家带来一款由css3和jquery实现的响应式设计导航.当显示器为pc时,导航为横条.当客户端为移动端时,呈现坚形导航.我们一起看下效果图: 在线预览    ...

  9. Grid – 入门必备!简单易懂的响应式设计指南

    如今,人们使用各种各样的移动设备访问网页,设计师们需要去适配不同的屏幕,让用户在都能有最佳的浏览体验.Grid 是一个简单的响应式设计指南,按照这些简单的步骤,你的就能够掌握基础的响应网页设计技巧. ...

随机推荐

  1. C#文件夹权限操作工具类

    using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Sec ...

  2. 【转】Tesla autopilot 引起致命车祸

    Tesla autopilot 引起致命车祸 好一段时间没关心 Tesla 了,今天才发现他们的 autopilot 终于引起了致命的车祸.这场 Model S 撞上18轮大卡车的车祸,发生于5月7号 ...

  3. 【转】我为什么离开 Cornell

    我为什么离开 Cornell 很多人都知道,我曾经在 Cornell 博士就读,两年之后转学到了 Indiana 大学.几乎所有人,包括 Indiana 大学的人都感觉奇怪,为什么会有人从 Corne ...

  4. Linux引导启动程序 - boot

    主要描述 boot/目录中的三个汇编代码文件,见列表 3-1 所示.正如在前一章中提到的,这三个 文件虽然都是汇编程序,但却使用了两种语法格式.bootsect.s 和 setup.s 采用近似于 I ...

  5. 第3章 Python基础-文件操作&函数 文件操作 练习题

    一.利用b模式,编写一个cp工具,要求如下: 1. 既可以拷贝文本又可以拷贝视频,图片等文件 2. 用户一旦参数错误,打印命令的正确使用方法,如usage: cp source_file target ...

  6. Qt Creator中如何添加C++0x支持

    最近在学习多线程编程,本人平时习惯使用Qt Creator写程序,只是作为C++编辑器,很少使用Qt library中的类. Multi Threading作为C++11标准已经纳入C++标准库了,可 ...

  7. Sql Server Compact 4.0数据库部署安装

    Sql Server Compact 4.0相比3.5版本增强了很多,支持Entity Framework 4.1,对于轻量级应用来讲,使用Sql Server Compact 4.0是个很好的选择, ...

  8. shell 计算时间差

    #!/bin/bash #date_5='awk 'BEGIN{print strftime("%H:%M",(systime()-300))}'' #ps -ef | grep ...

  9. cocos2d-x 模态对话框的实现

    心情不好,恩.不扯淡了.直接讲. ================================== 在泰然看了一篇实现模态对话框的文章,写的还不错,然后在其基础上加了我简单加了一层灰色透明背景,这 ...

  10. Vivado神器之DocNav

    Vivado2014安装完成以后会有2个文件出现在桌面上,具体如下图: 上一个是vivado的软件,是主要的工具,但是一定不要忽略下面一个DocNav,今天我要讲的就是这个工具,打开一个会看到这样一个 ...