页面缩放时元素CSS样式的问题

时间:2018-09-28 13:27:18

标签: css sass styles

我有一个简单的自定义切换开关CSS,当前我的问题是,当我将页面(例如使用Chrome)以70-80%的比例缩放时,滑块向左移动了一点,您可以看到滑块的红色背景拇指的左侧出现。附屏幕截图

如何解决此问题?我希望我的拇指/滑块位置在所有页面的所有缩放级别上都保持不变。

例如,如果您使用chrome(缩放比例在25-33%之间),也会发生相同的问题

屏幕截图出现问题的屏幕缩放比例为70-80%

.switch-input {
 display: none;
}
.switch-label {
  position: relative;
  display: inline-block;
  cursor: pointer;
  font-weight: 500;
  text-align: left;
}
.switch-label:before, .switch-label:after {
  content: "";
  position: absolute;
  margin: 0;
  outline: 0;
  top: 50%;
  -ms-transform: translate(0, -50%);
  -webkit-transform: translate(0, -50%);
  transform: translate(0, -50%);
  -webkit-transition: all 0.3s ease;
  transition: all 0.3s ease;
}
.switch-label:before {
  left: 1px;
  width: 34px;
  height: 14px;
  background-color: red;
  border-radius: 10px;
}
.switch-label:after {
  left: 0;
  width: 20px;
  height: 20px;
  background-color: #FAFAFA;
  border-radius: 50%;
}
<div>
    Input: <input type="checkbox" id="id-name--1" name="set-name" class="switch-input"  />
        <label for="id-name--1"  class="switch-label"/>
</div>

0 个答案:

没有答案
相关问题