純HTML和CSS實現點擊切換


<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
    <style>
    img {
      display: none;
      width: 100px;
      height: 100px;
    }
    input:checked + img {
      display: block;
    }
    input {
      position: absolute;
      left: -9999px;
    }
    label {
      cursor: pointer;
    }
    </style>
  </head>
  <body>
    <div id="cont">
      <input id="img1" name="img" type="radio" checked="checked">
      <img src="./img1.png" style="background: red">
      <input id="img2" name="img" type="radio">
      <img src="./img2.png" style="background: black">
    </div>
    <div id="nav">
      <label for="img1">第一張</label>
      <label for="img2">第二張</label>
    </div>
  </body>
</html>

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM