首页 > 语言 > JavaScript > 正文

js+css实现tab菜单切换效果的方法

2024-05-06 14:47:07
字体:
来源:转载
供稿:网友

本文实例讲述了js+css实现tab菜单切换效果的方法。分享给大家供大家参考。具体实现方法如下:

index.css如下:

代码如下:* { 
    margin: 0px; 
    padding: 0px; 

body { 
    width: 600px; 
    margin: 0 auto; 
    background-color: silver; 

 
#contanier { 
    background-color: yellow; 
    width: 600px;height: 400px; 

 
#tabNavi { 
    width: 600px;height: 30px; 
    background-color: #00bfff; 
    text-decoration: none; 
    list-style-type: none; 

 
#tabNavi li { 
    float: left; 
    margin-right: 7px; 
     background-color: #008b8b; 
    color: white; 
    cursor: pointer; 
    width: 60px; 
    height: 28px; 
    line-height: 30px; 
    text-align: center; 

#content { 
    width: 600px;height: 370px; 
    background-color: white; 
}

index.html如下:
代码如下:<!DOCTYPE html> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
    <title>js实现tab菜单动态切换效果</title> 
    <link href="css/index.css" rel="stylesheet" /> 
    <script type="text/javascript"> 
        function gel(id) { 
            return document.getElementById(id); 
        } 
 
        var arr = [ 
            { "title": "新闻", "content": "这是新闻频道" }, 
            { "title": "财经", "content": "这是财经频道" }, 
            { "title": "娱乐", "content": "这是娱乐频道" }, 
            { "title": "体育", "content": "这是体育频道" }, 
            { "title": "汽车", "content": "这是汽车频道" }, 

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选