【发布时间】:2022-11-18 07:26:27
【问题描述】:
您好,我的页面上有一个切换开关和微调器。我希望微调器在拨动开关关闭时停止旋转或消失。我相信为此我需要某种 javascript,但我是新手。请协助为此编写关于如何根据 .switch 值执行微调器的 javascript。
.html 页面
@keyframes spinner { 0% { transform: translate3d(-50%, -50%, 0) rotate(0deg); } } 100% { transform: translate3d(-50%, -50%, 0) rotate(360deg); } .switch { position: relative; display: inline-block; width: 55px; height: 28px; } .spin::before { animation: 1.5s linear infinite spinner; animation-play-state: inherit; border: solid 5px #cfd0d1; border-bottom-color: #1c87c9; border-radius: 50%; content: ""; height: 20px; width: 20px; position: absolute; top: 26%; left: 35%; transform: translate3d(-50%, -50%, 0); will-change: transform; } .switch { position: relative; display: inline-block; width: 55px; height: 28px; } .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #ccc; -webkit-transition: .4s; transition: .4s; } .slider:before { position: absolute; content: ""; height: 20px; width: 20px; left: 4px; bottom: 4px; background-color: white; -webkit-transition: .4s; transition: .4s; } input:checked + .slider { background-color: #2196F3; } input:focus + .slider { box-shadow: 0 0 1px #2196F3; } input:checked + .slider:before { -webkit-transform: translateX(26px); -ms-transform: translateX(26px); transform: translateX(26px); } <span class="slider round"></span> <div class="spin"></div>
【问题讨论】:
-
已发布代码中的第一个
@keyframes spinner块似乎缺少}。
标签: javascript html css