【发布时间】:2020-08-13 09:47:48
【问题描述】:
我在设计这个元素的样式时有点吃力。我以前从未这样做过,我真的找不到解决问题的方法。
我只想添加 border-radius 到边缘,添加一些 box-shadow 到那个点,这是可拖动的,我问的主要原因是,如何将较低的不透明度添加到尚未选择的一侧。
我不知道它是否必须通过 Javascript 来完成,或者我可以简单地用 css 来完成,但我的问题是:
这就是我的范围现在的样子
我的目标是这个
由于我以前从未设置过此元素的样式,所有这些 css 都来自我在 Google 上找到的多篇文章。有没有像 background:active 和 background:unactive 这样的东西?
谢谢。
.container{
background-color:red;
width:30%;
padding:1em;
text-align:center;
}
input[type="range"]{
width: 100%;
}
input[type=range]{
-webkit-appearance: none;
}
input[type=range]::-webkit-slider-runnable-track {
height: .35em;
background: white;
border: none;
border-radius: 3px;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
border: none;
height: 1.1em;
width: 1.1em;
border-radius: 50%;
background: white;
margin-top: -4px;
}
input[type=range]:focus {
outline: none;
}
<div class="container">
<div className="range">
<p className="heading">HEIGHT</p>
<input type="range"></input>
<p className="heading">WEIGHT</p>
<input type="range"></input>
</div>
</div>
【问题讨论】:
-
所以您会根据滑块值更改样式?这在 javascript 中可能更容易