zoukankan      html  css  js  c++  java
  • js常用特效——选项卡效果

     1 <!DOCTYPE html>
     2 <html>
     3     <head>
     4         <meta charset="UTF-8">
     5         <title></title>
     6         <style type="text/css">
     7             *{
     8                 margin: 0px;
     9                 padding: 0px;
    10                 list-style: none;
    11             }
    12             ol>li{
    13                 width: 50px;
    14                 height: 30px;
    15                 text-align: center;
    16                 line-height: 30px;
    17                 color: red;
    18                 background: #e0e0e0;
    19                 display: inline-block;
    20                 margin-right: 3px;
    21                 font-weight: bold;
    22                 cursor: pointer;
    23             }
    24             ul{
    25                 margin: 100px 0px 0px 100px;
    26                 position: relative;
    27             }
    28             ul>li{
    29                 width: 300px;
    30                 height: 200px;
    31                 font-size: 40px;
    32                 color: #fff;
    33                 position: absolute;
    34                 top: 0px;
    35                 left: 0px;
    36                 display: none;
    37             }
    38             ul>li:nth-of-type(1){
    39                 background: #ff6700;
    40             }
    41             ul>li:nth-of-type(2){
    42                 background: green;
    43             }
    44             ul>li:nth-of-type(3){
    45                 background: blue;
    46             }
    47             .show{
    48                 display: block;
    49             }
    50             .bg{
    51                 background: #FF6700;
    52                 color: white;
    53             }
    54         </style>
    55     </head>
    56     <body>
    57         <ol id="ol">
    58             <li>1</li>
    59             <li>2</li>
    60             <li>3</li>
    61         </ol>
    62         <ul id="ul">
    63             <li>A</li>
    64             <li>B</li>
    65             <li>C</li>
    66         </ul>
    67         <script type="text/javascript">
    68             var li = document.querySelectorAll("ol li");
    69             var lis = document.querySelectorAll("ul li");
    70             
    71             lis[0].className="show";
    72             li[0].className = "bg";
    73             for(var i=0;i<li.length;i++){
    74                 li[i].index = i;
    75                 li[i].onmouseover = function(){
    76                     clear();
    77                     this.className = "bg";
    78                     lis[this.index].className = "show";
    79                 }
    80             }
    81             
    82             function clear(){
    83                 for(var j=0;j<lis.length;j++){
    84                     lis[j].className="";
    85                     li[j].className="";
    86                 }
    87             }
    88         </script>
    89     </body>
    90 </html>
    认真是一种态度。。。求知若饥,虚怀若愚
  • 相关阅读:
    SAP SD 模块面试题
    商品ATP check FM(获得可用库存和总库存)
    获得SO的凭证流
    SAP XI 常用事务代码
    ABAP 面试问题及答案(一)(转)
    ABAP 面试题(转)
    SAP XI 3.0考试大纲
    Enterprise System Applicaiton 试题
    Enterprise Portal 试题
    ABAP 100 道面试题
  • 原文地址:https://www.cnblogs.com/web-wjg/p/7136773.html
Copyright © 2011-2022 走看看