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

效果图:

点击后的效果:


可以通过 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. dubbo的rpc异常

    Exception in thread "main" com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method ...

  2. PHP.14-图片处理类

    图片处理类 test.php <?php include "images.class.php"; $image=new Image("./images/" ...

  3. 11,nginx入门与实战

      网站服务 想必我们大多数人都是通过访问网站而开始接触互联网的吧.我们平时访问的网站服务 就是 Web 网络服务,一般是指允许用户通过浏览器访问到互联网中各种资源的服务. Web 网络服务是一种被动 ...

  4. Fiddler - 使用教程

    1.断点调试,修改请求表单和响应数据 命令介绍: bpu在请求开始时中断,bpafter在响应到达时中断,bps在特定http状态码时中断,bpv/bpm在特定请求method时中断. bpu m.t ...

  5. 二分查找问题(Java版)

    二分查找问题(Java版)   1.一般实现 package search;   /**  * @author lei 2011-8-17  */ public class BinarySearch ...

  6. oracle集群部署相关文章

    1. Oracle数据库HA架构方案介绍:http://blog.sina.com.cn/s/blog_7273b6cc0100p0sr.html 2.Oracle 集群概念和原理

  7. 【Gradient Boosted Decision Tree】林轩田机器学习技术

    GBDT之前实习的时候就听说应用很广,现在终于有机会系统的了解一下. 首先对比上节课讲的Random Forest模型,引出AdaBoost-DTree(D) AdaBoost-DTree可以类比Ad ...

  8. Synology DS213J 群晖NAS git server架设方法!

    最近单位购入一台Synology  DS213J用作数据存储. 本人打算将一些项目的源代码也放在上面,他本身的套件中心提供了SVN SERVER和GIT SERVER. 设置SVN SERVER非常简 ...

  9. flask_入门教程之一

    一.教程涉及开发语言.脚本.框架.数据库等内容 Python + Flask + requests 通过命令安装:pip install flask 二.创建第一个flask脚本 一个最小的 Flas ...

  10. 从今天开始学Python

    外部链接下载吧 1.  Python 3.63.chm   AIP 帮助文档  下载:https://pan.baidu.com/s/1lhpv8JTC3Z7B6aZ3qQi40g 2.  VMwar ...