javascript实现不同颜色Tab标签切换效果
作者:木风622 发布时间:2024-02-24 16:14:35
标签:js,Tab,标签,切换
本文实例为大家分享了javascript不同颜色Tab标签切换效果的实现代码,供大家参考,具体内容如下
具体代码:
<html>
<head>
<title>不同颜色选项卡</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"/>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
body {
font: 12px/20px 'microsoft yahei', 'arial';
word-break: break-all;
word-wrap: break-word;
}
.clearfix:after {
content: '.';
display: block;
clear: both;
height: 0;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
#wrap {
width: 320px;
margin: 2em auto;
}
.card_List {
height: 30px;
border-bottom: 1px solid #f00;
position: relative;
}
.card_List li {
float: left;
width: 68px;
text-align: center;
height: 30px;
line-height: 30px;
margin: 0 5px;
display: inline;
border-top-left-radius: 6px;
border-top-right-radius: 6px;
}
.card_List li.current {
height: 34px;
line-height: 34px;
margin-top: -4px;
border: 1px solid #F00;
background: #FF9494;
border-bottom: none;
color: #fff;
}
#oLi li:nth-child(1){
background: #FF9494;
}
#oLi li:nth-child(2){
background: #8CFE8C;
}
#oLi li:nth-child(3){
background: #6969FB;
}
#oLi li:nth-child(4){
background: #FFE26F;
}
.card_content div {
display: none;
height: 100px;
text-align: center;
color: #000;
}
.card_content div:first-child {
background: #fff;
}
</style>
<script type="text/javascript">
window.onload = function () {
var colorArr = {
0:"#f00",
1:"#0f0",
2:"#00f",
3:"#FC0"
};
var bgColorArr = {
0:"#fff",
1:"#fff",
2:"#fff",
3:"#fff",
}
var oL = document.getElementById("oLi");
var oLi = oL.getElementsByTagName("li");
var oUl = document.getElementById("oUl").getElementsByTagName("div");
for ( var i=0 ; i<oLi.length ; i++ ){
oLi[i].index = i;
oLi[i].onclick = function () {
for ( var j = 0 ; j < oLi.length ; j++ ){
oLi[j].className = "";
oLi[j].style.border = "none";
}
this.className = "current";
this.style.border = "1px solid " + colorArr[this.index];
this.style.borderBottom = "none";
oL.style.borderBottom = "1px solid " + colorArr[this.index];
for ( var j=0 ; j < oUl.length ; j++ ){
oUl[j].style.display = "none";
oUl[this.index].style.display = "block";
oUl[j].style.backgroundColor = bgColorArr[this.index];
}
};
}
};
</script>
</head>
<body>
<div id="wrap">
<ul id="oLi" class="card_List clearfix">
<li class="current">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<div id="oUl" class="card_content">
<div style="display:block;">
11111111111111
</div>
<div>
22222222222
</div>
<div>
3333333333333
</div>
<div>
44444444444444444
</div>
</div>
</div>
</body>
</html>


猜你喜欢
- 引言近期在好几个地方都看到meshgrid的使用,虽然之前也注意到meshgrid的用法。但总觉得印象不深刻,不是太了解meshgrid的应
- 本文实例讲述了python通过pil为png图片填充上背景颜色的方法。分享给大家供大家参考。具体分析如下:png图片有些是没有背景颜色,如果
- 在实际编程开发中,我们会使用到各类的加密算法来对数据和信息进行加密。比如密码中比较常见的MD5加密,以及AES加密等等。对于密码认证来说,M
- 原理经度 phi,纬度 theta 处的坐标为:x =R* cos(phi) * cos(theta)y = Rsin(phi) * cos
- 本文实例为大家分享了python实现烟花小程序的具体代码,供大家参考,具体内容如下'''FIREWORKS SIMU
- 本文实例为大家分享了JavaScript实现点击出现子菜单的具体代码,供大家参考,具体内容如下首先让我们看一下点击出现子菜单的效果如下图:点
- 导入模块import numpy as npimport pandas as pd1.读取测试数据data=pd.read_csv(r
- 一、什么是XSS攻击xss攻击:----->web注入xss跨站脚本攻击(Cross site script,简称xss)是一种“HT
- 之前用bash实现过(https://www.jb51.net/article/61943.htm),不过那个不能在windows下使用,所
- 问题你正在试着使用正则表达式去匹配一大块的文本,而你需要跨越多行去匹配。解决方案这个问题很典型的出现在当你用点(.)去匹配任意字符的时候,忘
- 前言为了数据安全,数据库需要定期备份,这个大家都懂,然而数据库备份的时候,最怕写操作,因为这个最容易导致数据的不一致,松哥举一个简单的例子大
- 1、前言最近在做微信公众号开发在进行网页授权时,微信需要用户自己在授权url中带上一个类似token的state的参数,以防止跨站攻击。在经
- 源码:#!/usr/bin/env python# -*- coding:utf-8 -*- import turtleimport tim
- 目前很多软件都限制单实例,大多数软件都是用Mutex来实现的 而这个东西咱们可以用handle去干掉它,并且不影响使用。 钉钉也是一样的步骤
- Django带来了一个高级的聚合生成框架,它使得创建RSS和Atom feeds变得非常容易。什么是RSS? 什么是Atom?RSS和Ato
- 笔者认为,在创建索引时要做到三个适当,即在适当的表上、适当的列上创建适当数量的索引。虽然这可以通过一句话来概括优化的索引的基本准则,但是要做
- 在Python中,正则表达式的group和groups方法是非常有用的函数,用于处理匹配结果的分组信息。group方法是re.MatchOb
- 一、watch 默认是浅层,使用deep深层监听被侦听的 property,仅在被赋新值时,才会触发回调函数—&
- //User 用户的基本信息,也是USERINFO表中的3个列package 登陆判断;public class User { &
- 标准库的fnmatch库专门用来进行文件名匹配,支持使用通配符进行字符串匹配。1、fnmatch:判断文件名是否符合特定的模式;2、fnma