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

效果图:

点击后的效果:


可以通过 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. 1 HTML + CSS

    1.HTML的基础用法 2.标签的嵌套 3.常见的网页结构 header content footer

  2. Centos7 查看Mysql配置文件

    my.cnf是mysql启动时加载的配置文件,一般会放在mysql的安装目录中,用户也可以放在其他目录加载. 安装mysql后,系统中会有多个my.cnf文件,有些是用于测试的. 使用locate m ...

  3. 关于requestMapping 进行url映射实现小小知识点 以及如何获取请求的url中的参数

    requstMapping 用来处理url映射  可以作用在controller类上  也可以作用在方法上 经常使用的方式  通过接收一种映射关系 @RequestMapping("/del ...

  4. Invalid bound statement (not found): com.up.sell.mapper.system.H5operationMapper.

    springboot + mybatis项目,出现这样的错误原因就是mapper类的名字和xml的id不对应或者是忘记写了,仔细检查一下吧

  5. cjson 增强对逗号处理

    https://sourceforge.net/projects/cjson/ 解析JSON比较好的轻量级工具,使用比较方便,今天测试发现有些JSON解析失败,但其他工具可以正常解析. 跟踪发现是cJ ...

  6. cycling -avoid the vicious cycle

    ‘Numerous' studies in the past appear to have shown a link between cycling and ED. The researchers a ...

  7. 【Text Justification】cpp

    题目: Given an array of words and a length L, format the text such that each line has exactly L charac ...

  8. 项目中使用ECharts插件实现统计功能

    一.前端界面 // 界面中定义一个div,放图表 <div id="box" style="width: 600px;height:400px;padding: 1 ...

  9. cookie换肤功能

    <div class="selectSkin"> <input id="red" class="themeBtn" typ ...

  10. NodeJs06 高并发

    高并发架构 在业务的最初期,由于业务和用户的体量比较小,可能采用单机就足够了.随着业务的增长,用户量和并发请求量都会不断上升.当增长到一定的瓶颈的时候,系统能否抗住压力,就需要采取一些方案了.这就是著 ...