18910140161

html-如何创建一个外部有环的圆形输入按钮?-堆栈溢出

顺晟科技

2022-10-19 11:56:06

207

这是我现在正在工作的。只是想知道如何在它里面添加另一个小圆圈,以使它与我上面包含的图像完全相同。

我正试图复制这个。我不确定如何使用CSS实现这种方式。目前,我只是有一个圆圈复选框工作。不确定如何添加环或缩小内圈。


顺晟科技:

Alexander很好地说明了这是否更适合在语义上作为单选按钮。

不管怎样,添加带有间隙的边框的方法是组合和:

/* The container */
.container {
  display: block;
  position: relative;
  padding-left: 35px;
  margin-bottom: 12px;
  cursor: pointer;
  font-size: 22px;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* Hide the browser's default radio button */
.container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

/* Create a custom radio button */
.checkmark {
  position: absolute;
  top: 0;
  left: 0;
  height: 28px;
  width: 28px;
  background-color: #eee;
  border-radius: 50%;
}

/* On mouse-over, add a grey background color */
.container:hover input ~ .checkmark {
  background-color: #0f8c73;
}

/* When the radio button is checked, add a blue background */
.container input:checked ~ .checkmark {
  background-color: #0f8c73;
}

/* Create the indicator (the dot/circle - hidden when not checked) */
.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

/* Show the indicator (dot/circle) when checked */
.container input:checked ~ .checkmark:after {
  display: block;
}

/* Style the indicator (dot/circle) */
.container .checkmark:after {
    top: 3.5px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: white;
}

下面的操作片段:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航