<label>
开
<input type="checkbox" role="switch" class="mouse" />
关
</label>
HTML
格式化
支持Emmet,输入 p 后按 Tab键试试吧!
<head> ... </head>
<body>
</body>
body {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
overflow: hidden;
margin: 0;
min-height: 100vh;
font-size: 3.5vmin;
gap: 0.25em;
}
label {
display: flex;
align-items: center;
gap: 3vw;
}
@keyframes blink {
0%, 6%, 100% { mask: radial-gradient(100% 0% at 50% 55%, #0000 99%, #000); }
3% { mask: radial-gradient(100% 5% at 50% 55%, #0000 99%, #000); }
}
.mouse {
--fur: lightgray;
--skin: #fdd;
--time: 0.3s;
appearance: none;
position: relative;
font-size: 1em;
box-sizing: content-box;
height: 2.5em;
width: 2em;
border: 1px solid #0000;
background:
radial-gradient(50% 100% at 50% 0, #0003 70%, #0000) 0 100% / 50% 50% no-repeat,
var(--fur);
background-position: 0 100%;
transition: background-position var(--time), transform var(--time);
transform-origin: 50% 100%;
transform: skew(3deg);
&::before {
content: "";
position: absolute;
top: 0;
left: 50%;
transform: translateX(-50%);
width: 168%;
height: 90%;
clip-path: polygon(80% 0, 80% 60%, 0% 95%, 20% 0%);
aclip-path: polygon(80% 0, 50% 100%, 20% 0);
transition: clip-path var(--time);
background:
radial-gradient(80% 110% at 50% 0, #0000 90%, #000 0),
linear-gradient(var(--fur) 87%, #000 0);
border-radius: 0 0 20% 20%;
pointer-events: none;
}
&::after {
content:"";
position: absolute;
bottom: 0;
left: 50%;
width: 180%;
height: 150%;
background:
/* ears */
radial-gradient(closest-side circle at 22% 22%, var(--skin) 66%, #0000 0),
radial-gradient(closest-side circle at 78% 22%, var(--skin) 66%, #0000 0),
radial-gradient(closest-side circle at 20% 20%, var(--fur) 99%, #0000),
radial-gradient(closest-side circle at 80% 20%, var(--fur) 99%, #0000),
/* eyes */
radial-gradient(circle at 48% 53%, #fff 0.05em, #0000 0) 0 0 / 50% 100% no-repeat,
radial-gradient(circle at 88% 53%, #fff 0.05em, #0000 0) 0 0 / 50% 100% no-repeat,
radial-gradient(circle at 50% 55%, #000 0.15em, #0000 0) 0 0 / 50% 100% no-repeat,
radial-gradient(circle at 90% 55%, #000 0.15em, #0000 0) 0 0 / 50% 100% no-repeat;
background-position: 0 0;
transform: translate(-50%);
transition: background-position var(--time);
pointer-events: none;
mask: radial-gradient(100% 5% at 50% 55%, red 99%, #0000);
animation: blink 4s infinite;
}
&:checked {
background-position: 100% 100%;
transform: skew(-3deg);
&::before {
clip-path: polygon(20% 0, 80% 0, 100% 95%, 20% 60%);
}
&::after {
background-position: 60% 0;
}
}
&[disabled] {
opacity: 0.25;
}
}
@media print {
.mouse {
&, &::before, &::after {
-webkit-print-color-adjust: exact;
print-color-adjust: exact;
}
}
}
@media (prefers-reduced-motion) {
.mouse {
&, &::before, &::after {
transition: none !important;
animation: none !important;
}
}
}