App下載
首頁htmlappearanceCSS Property Value - 如何創(chuàng)建純CSS圖像切換

CSS Property Value - 如何創(chuàng)建純CSS圖像切換

我們想知道如何創(chuàng)建純CSS圖像切換。

<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
input[type="checkbox"] {
  content: url('http://placehold.it/200x200');
  display: block;
  width: 200px;
  height: 200px;
}

input[type="checkbox"]:checked {
  content: url('http://placehold.it/210x210');
}

.native-hidden {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}
</style>
</head>
<body>
  <input class="native-hidden" type="checkbox" />
  Click image to see the change
</body>
</html>