(如有错敬请指点,以下是我工作中遇到并且解决的问题)

效果图:

点击后的效果:


可以通过 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过渡效果的更多相关文章

  1. 第八十二节,CSS3过渡效果

    CSS3过渡效果 学习要点: 1.过渡简介 2.transition-property 3.transition-duration 4.transition-timing-function 5.tra ...

  2. 设置 TabBarItem 选中时的图片及文字颜色

    TabBarController 是在 ios 开发过程中使用较为频繁的一个 Controller,但是在使用过程中经常会遇到一些问题,例如本文所要解决的,如何修改 TabBar 选中时文字及图片的颜 ...

  3. 转 Android RadioButton设置选中时文字和背景颜色同时改变

    主要应用在购物车,像淘宝的那样,点击以后弹出一个选择种类颜色这样的popuwindow以后,然后这个选择种类的地方要用到类似这个玩意儿. 搜了一下,效果和这个文章一致.转了. 原文地址:http:// ...

  4. IOS - UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 [cpp] view plaincopy //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 ...

  5. UITableViewCell的选中时的颜色设置

    转自:http://hi.baidu.com/zhu410289616/item/0de0262910886011097508c2 1.系统默认的颜色设置 //无色 cell.selectionSty ...

  6. IOS中设置cell的背景view和选中时的背景view 、设置cell最右边的指示器(比如箭头\文本标签)

    一.Cell的设置 1.设置cell的背景view和选中时的背景view UIImageView *bg = [[UIImageView alloc] init]; bg.image = [UIIma ...

  7. 设置TabBarItem选中时的图片及文字颜色

    TabBarItem选中时,默认文字和图片都变为蓝色.使用以下代码可以进行修改. MainViewController *mainVC = [[MainViewController alloc] in ...

  8. 【转】iOS开发UITableViewCell的选中时的颜色设置

    原文网址:http://mobile.51cto.com/hot-404900.htm 1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSe ...

  9. UITableViewCell的选中时的颜色及tableViewCell的selecte与deselecte

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

随机推荐

  1. mybatis异常:There is no getter for property named 'xxx' in 'xxx'

    在使用mybatis查询的时候出现了下面的异常: org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  2. FTP使用心得

    1、创建文件夹的函数,一次只能创建一层。 2、没有现成的判断文件夹是否存在的函数,如果文件夹不存在就创建,会报异常。有以下封装好的函数。可以直接调用。 1 2 3 4 5 6 7 8 9 10 11 ...

  3. 剑指Offer - 九度1511 - 从尾到头打印链表

    剑指Offer - 九度1511 - 从尾到头打印链表2013-11-29 21:08 题目描述: 输入一个链表,从尾到头打印链表每个节点的值. 输入: 每个输入文件仅包含一组测试样例.每一组测试案例 ...

  4. 关于JavaScript设计模式的学习(二)

    第二部分来了,是关于结构型的,同样的,还是在简书中,GitHub上也有代码示例和详细注释 简书:http://www.jianshu.com/p/face1be4b846 github:https:/ ...

  5. shell之echo and printf

    #!/bin/sh _________echo___________#read name #echo "$name It is a test" #read命令从标准的输入中读取一行 ...

  6. C++ Primer 第3章 字符串、向量和数组

    C++ Primer 第3章 字符串.向量和数组 C Primer 第3章 字符串向量和数组 1 命名空间的using声明 2 标准库类型string 3 标准库类型vector 4 迭代器介绍 5 ...

  7. poj 2299 归并排序求逆序数 (可做模板)

    Time Limit: 7000MS   Memory Limit: 65536K Total Submissions: 48077   Accepted: 17533 Description In ...

  8. 软考——(5)计算机系统之CPU组成

    其实我们很早就接触过计算机系统方面的知识,但是还是出现印象不深,理解不清楚的现象,丢分很严重.这部分的知识需要我们花功夫去理解,因为很多东西我们接触不到,比如校验码.码制等,如果你不去理解而是去记,就 ...

  9. 将MSHFlexGrid1中记录导出为Excel

    1.添加引用Microsoft Excel 14.0 Object Library 2.编写代码部分 Private Sub Output_Click() Dim i As Integer '定义变量 ...

  10. [NOWCODER] myh的超级多项式

    题面 已知$f_i=(\sum_{j=1}^ka_j{v_j}^i )\bmod 1004535809$ 给定$v_1,v_2,\ldots,v_k,f_1,f_2,\ldots f_k$ 求$f_n ...