菜单栏选中时CSS3过渡效果
(如有错敬请指点,以下是我工作中遇到并且解决的问题)
效果图:
点击后的效果:



可以通过 https://littlehiuman.github.io/07-menus/index-2.html 查看效果。
https://github.com/littleHiuman/littleHiuman.github.io 求点star~~~
HTML:
<ul class="menus">
<li class="active">菜单1</li>
<li>菜单2</li>
<li>菜单3</li>
<li>菜单4</li>
<li>菜单5</li>
<li>菜单6</li>
<li class="bar"><i class="active_bg"></i></li>
</ul>
CSS:
* {
margin:;
padding:;
list-style: none;
}
ul {
height: 40px;
position: relative;
line-height: 44px;
}
ul li {
width: 16.66666%;
height: 100%;
float: left;
color: #999;
text-align: center;
cursor: pointer;
}
ul .bar {
width: 16.66666%;
height: 3px;
line-height:;
position: absolute;
left:;
bottom: 1px;
transform: translateX(0%);
transition: 0.2s linear;
-webkit-transition: 0.2s linear;
}
ul .bar i {
width: 70%;
height: 3px;
display: inline-block;
}
.active {
color: darkgreen;
}
.active_bg {
background-color: darkgreen;
}
JAVASCRIPT:
var menus = document.querySelector('.menus');
var children = menus.children;
for (var i = 0; i < children.length; i++) {
children[i]['data-index'] = i;
}
menus.onclick = function (event) {
event = event || window.event;
if (event.target.tagName === 'LI') {
for (var i = 0; i < children.length; i++) {
children[i].className = children[i].className.replace(/active/, '')
}
event.target.className += ' active';
children[children.length - 1].style['-webkit-transform'] = 'translateX(' + (event.target['data-index'] * 100) + '%)'
}
}
菜单栏选中时CSS3过渡效果的更多相关文章
- 第八十二节,CSS3过渡效果
CSS3过渡效果 学习要点: 1.过渡简介 2.transition-property 3.transition-duration 4.transition-timing-function 5.tra ...
- 设置 TabBarItem 选中时的图片及文字颜色
TabBarController 是在 ios 开发过程中使用较为频繁的一个 Controller,但是在使用过程中经常会遇到一些问题,例如本文所要解决的,如何修改 TabBar 选中时文字及图片的颜 ...
- 转 Android RadioButton设置选中时文字和背景颜色同时改变
主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...
- IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte
1.系统默认的颜色设置 [cpp] view plaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 ...
- UITableViewCell的选中时的颜色设置
转自:http://hi.baidu.com/zhu410289616/item/0de0262910886011097508c2 1.系统默认的颜色设置 //无色 cell.selectionSty ...
- IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)
一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...
- 设置TabBarItem选中时的图片及文字颜色
TabBarItem选中时,默认文字和图片都变为蓝色.使用以下代码可以进行修改. MainViewController *mainVC = [[MainViewController alloc] in ...
- 【转】iOS开发UITableViewCell的选中时的颜色设置
原文网址:http://mobile.51cto.com/hot-404900.htm 1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSe ...
- UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte
1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...
随机推荐
- div+css实现双飞翼布局
本例通过div+css实现HTML金典布局双飞翼布局,该布局结构为上中下结构,上:header头:下:footer尾:中:内容,将内容分为了三个结构,左中右 下图是效果图 我们来看下代码 <!D ...
- erlang中的原子(atom)内部实现[转]
转自: http://www.kongqingquan.com/archives/208#more-208 Erlang中的atom由通用hash表实现,虚拟机中atom最终的用数值表示,对应表中的下 ...
- 《Cracking the Coding Interview》——第3章:栈和队列——题目7
2014-03-19 03:20 题目:实现一个包含阿猫阿狗的先入先出队列,我要猫就给我一只来的最早的猫,要狗就给我一只来的最早的狗,随便要就给我一只来的最早的宠物.建议用链表实现. 解法:单链表可以 ...
- express 热启动 静态文件部署 跨域解决 调试
1.热启动 每次修改app.js文件,都得重新启动项目,十分不方便.这里可以用hotnode插件实现热启动 安装:$ npm install -g hotnode 启动项目:$ hotnode app ...
- 从今天开始学Python
外部链接下载吧 1. Python 3.63.chm AIP 帮助文档 下载:https://pan.baidu.com/s/1lhpv8JTC3Z7B6aZ3qQi40g 2. VMwar ...
- 使用dib element proliant-tools制作deploy image
element proliant-tools会在ipa ramdisk中安装一个rpm包hpssacli(HP的RAID管理工具),和一个python module proliantutils(里面P ...
- hp raid配置
http://www.cnblogs.com/zhangxinglong/p/5585139.html [root@192e168e100e27 ~]# fdisk -l Disk /dev/nvme ...
- ThreadLocal 学习
JDK 1.2版本就已经提供了java.lang.ThreadLocal.其为多线程程序的并发问题提供了一种新的思路.使用该工具类可以简洁地编写出优美的多线程程序. 当使用ThreadLocal维护变 ...
- springboot10 framwork
一.Spring介绍 Spring 是位于业务逻辑层的框架. 优点很多(无缝对接前后层的框架.提供AOP的支持 , 和以前的 Sstruts . Hibernate 组合成了一套框架组合 SSH .现 ...
- 解决:spring security 登录页停留时间过长 跳转至 403页面
前言:最近的项目中用到了spring security组件,说句显low的话:我刚开始都不知道用了security好不勒,提了bug,在改的过程中,遇到了一些问题,找同事交流,才知道是用的securi ...