纯HTML和CSS实现点击切换

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
    <style>
    img {
      display: none;
       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>

  

原文地址:https://www.cnblogs.com/detanx/p/htmlCssCcheck.html