如何使用原生HTML/CSS检测滑块的点击。

huangapple go评论54阅读模式
英文:

How to detect click with native html/css for slider

问题

我正在尝试仅使用HTML/CSS创建滑块。我正在使用输入和标签。

这是我的CSS代码。当元素被选中时,我将我的div向左移动。

.firstCat:checked ~ .carousel-wrapper div {
  left: 360px;
  transition: left 0.3s ease-in-out;
}

这是创建滑块的唯一方法吗?也许有更加优雅的解决方案。

英文:

I am trying to create slider only with html/css. I'm using inputs and labels.

This is my css code. I'm moving my div to left when element is checked.

.firstCat:checked ~ .carousel-wrapper div {
left: 360px;
transition: left 0.3s ease-in-out;
}

Is it the only way to create sider? Maybe you more elegant solution.

答案1

得分: 0

您可以使用

英文:
<input type="range" min="1" max="100" value="50" class="slider">

You can use input type "range".

huangapple
  • 本文由 发表于 2023年1月9日 03:38:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75050732.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定