1

Switch in single tag

 2 years ago
source link: https://codepen.io/vineethtrv/pen/NWyGqNR
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Pen Settings

HTML Preprocessor

Add Class(es) to <html>

Stuff for <head>

0 unsaved changes
xxxxxxxxxx
  <input class="switch" type="checkbox">
<input class="switch" type="checkbox" style="--size: 40px; --inactive-bg: #FF8A65; --active-bg: #4DB6AC">
xxxxxxxxxx
.switch {
  --inactive-bg: #cfd8dc;
  --active-bg: #00e676;
  --size: 2rem;
  appearance: none;
  width: calc(var(--size) * 2.2);
  height: var(--size);
  display: inline-block;
  border-radius: calc(var(--size) / 2);
  cursor: pointer;
  background-color: var(--inactive-bg);
  background-image: radial-gradient(
      circle calc(var(--size) / 2.1),
      #fff 100%,
      #0000 0
    ),
    radial-gradient(circle calc(var(--size) / 1.5), #0003 0%, #0000 100%);
  background-repeat: no-repeat;
  background-position: calc(var(--size) / -1.75) 0;
  transition: background 0.2s ease-out;
}
.switch:checked {
  background-color: var(--active-bg);
  background-position: calc(var(--size) / 1.75) 0;
xxxxxxxxxx

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK