• CSS特效(3)——target伪类实现tab切换


    target伪类实现tab切换

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta http-equiv="X-UA-Compatible" content="ie=edge">
      <title>Document</title>
      <style>
        .container {
          position: relative;
           400px;
          margin: 50px auto;
        }
    
        .nav {
          position: relative;
          overflow: hidden;
          padding:0;
        }
    
        li {
          list-style: none;
           200px;
          float: left;
          text-align: center;
          background: #ddd;
        }
    
        li a {
          display: block;
           200px;
          line-height: 36px;
          font-size: 18px;
          cursor: pointer;
          text-decoration: none;
          color: #000;
        }
    
        #content1,
        #content2 {
          position: absolute;
          overflow: hidden;
          top: 36px;
           400px;
          height: 100px;
          border: 1px solid #999;
          box-sizing: border-box;
          padding: 10px;
        }
    
        #content1,
        #content2 {
          display: none;
           100%;
          background: #fff;
        }
    
        #content1:target,
        #content2:target {
          display: block;
        }
    
        #content1.active {
          display: block;
        }
    
        .active~.nav li:first-child {
         
            background: #ff7300;
            color: #fff;
         
        }
    
        #content1:target~.nav li {
          background: #ddd;
          color: #000; 
          
        }
        #content1:target~.nav li:first-child {
            background: #ff7300;
            color: #fff;
          }
        #content2:target~.nav li {
          background: #ddd;
          color: #000; 
         
        }
        #content2:target~.nav li:last-child {
            background: #ff7300;
            color: #fff;
          }
        .wrap {
          position: absolute;
          overflow: hidden;
          top: 36px;
           400px;
          height: 100px;
          border: 1px solid #999;
          box-sizing: border-box;
        }
      </style>
    </head>
    
    <body>
      <div class="container">
        <div id="content1" class="active">列表1内容:123456</div>
        <div id="content2">列表2内容:abcdefgkijkl</div>
        <ul class='nav'>
          <li class="active">
            <a href="#content1">列表1</a>
          </li>
          <li>
            <a href="#content2">列表2</a>
          </li>
        </ul>
        <div class="wrap"></div>
      </div>
    </body>
    
    </html>
    
  • 相关阅读:
    Excel长数字防止转换为科学计数法
    SVN迁移部署
    且行且珍惜
    功能的权衡——推荐功能做不做?
    渗透小白如何学编程
    Metasploit log命令技巧
    Metasploit 使用msfconsole帮助功能技巧
    Metasploit resource命令技巧
    Metasploit makerc命令技巧
    Metasploit irb命令使用技巧
  • 原文地址:https://www.cnblogs.com/janas-luo/p/9604787.html
Copyright © 2020-2023  润新知