CSS - 如何在输入滑块按钮上使用伪元素/如何在伪元素上设置伪元素

CSS - How to use pseudo elements on a Input slider button / How to set a pseudo element on a pseudo element

我需要创建一个具有特定样式的滑块。滑块顶部的按钮需要在其中心有一个圆圈。为此,我尝试使用 ::before 伪元素。

但是我遇到了一个问题,无法让它正常工作。我认为问题在于在伪元素之上设置伪元素。但是我不知道如何实现这种类型的按钮。

我在滑块下方的代码片段中添加了结局设计:

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 0.1rem;
  background: #176D8A;
  outline: none;
  opacity: 1;
  -webkit-transition: .2s;
  transition: opacity .2s;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  background: #FFFFFF;
  cursor: pointer;
}

.slider::-moz-range-thumb {
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  background: #FFFFFF;
  cursor: pointer;
  border-radius: 100%;
}

.slider::-webkit-slider-thumb::before {
  content: "";
  
  position: absolute;
  top: 0;
  left: 0;
  width: 0.5rem;
  height: 0.5rem;
  background: #176D8A;
  border-radius: 100%;
  border: 1px solid black;
  
  display: flex;
  justify-content: center;
  align-items:center;
}

.slider::-moz-range-thumb::before {
  content: "";
  
  position: absolute;
  width: 0.5rem;
  height: 0.5rem;
  background: #176D8A;
  border-radius: 100%;
  border: 1px solid black;
}

.test{
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  background: #FFFFFF;
  cursor: pointer;
  border-radius: 100%;
  border: 1px solid black;
  
  display: flex;
  justify-content: center;
  align-items:center;
}

.test::before {
  content: "";
  
  position: absolute;
  width: 0.5rem;
  height: 0.5rem;
  background: #176D8A;
  border-radius: 100%;
}
<input type="range" min="1" max="100" value="50" class="slider" id="myRange">

<div class="test">
</div>

你不能使用伪元素所以把所有的样式放在拇指上

.slider {
  -webkit-appearance: none;
  width: 100%;
  height: 0.1rem;
  background: #176D8A;
  outline: none;
  opacity: 1;
  -webkit-transition: .2s;
  transition: opacity .2s;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 1.5rem;
  height: 1.5rem;
  background: radial-gradient(circle farthest-side,#176D8A .25em,#fff .26em);
  border: 1px solid black;
  cursor: pointer;
  border-radius: 100%;
}

.slider::-moz-range-thumb {
  position: relative;
  width: 1.5rem;
  height: 1.5rem;
  background: radial-gradient(circle farthest-side,#176D8A .25em,#fff .26em);
  border: 1px solid black;
  cursor: pointer;
  border-radius: 100%;
}
<input type="range" min="1" max="100" value="50" class="slider" id="myRange">

<div class="test">
</div>