gpt4 book ai didi

html - 切换按钮边框空间

转载 作者:太空宇宙 更新时间:2023-11-04 06:10:33 25 4
gpt4 key购买 nike

如屏幕截图所示,边框和背景之间有一些空间。它连接到 border-radius 和 overflow: hidden。如果我在所有地方删除边框半径,它就可以正常工作。我想删除那个间距。我在 Chrome 和 Firefox 上测试过它。

Screen Toggler 边框人工制品

Screen Toggler 边框伪像突出显示

.toggle {
display: inline-block;
position: relative;
overflow: visible;
height: auto;
width: 100%;
cursor: pointer;
}

.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track {
border-color: #4680fe;
}
.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track .toggle__circle {
transform: translate(0, 0);
}
.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track .toggle__handler {
transition: left 250ms ease-in-out 50ms, right 250ms ease-in-out, background-color 250ms ease-in-out;
left: 24px;
right: 0;
background-color: white;
}

.input--hidden {
position: absolute;
left: 0px;
cursor: inherit;
pointer-events: all;
opacity: 0;
width: 100%;
height: 100%;
z-index: 1;
padding: 0px;
margin: 0px;
}

.input__row {
position: relative;
display: flex;
width: 100%;
height: 100%;
}

.toggle__container {
display: flex;
flex-shrink: 0;
position: relative;
box-sizing: border-box;
}

.toggle__track {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
box-sizing: border-box;
border-radius: 12px;
transition: border 250ms 0ms linear;
background-color: transparent;
box-shadow: 0 1px 1px rgba(70, 128, 254, 0.1);
border: 2px solid rgba(70, 128, 254, 0.4);
}

.toggle__circle {
display: block;
position: absolute;
top: -2px;
left: -2px;
transform: translate(-100%, 0);
transition: transform 250ms 0ms cubic-bezier(0.165, 0.84, 0.44, 1);
border-radius: 12px;
background-color: #4680fe;
}

.toggle__container,
.toggle__circle {
width: 48px;
height: 24px;
}

.toggle__handler {
position: absolute;
top: 0;
left: 0;
height: 16px;
margin: 2px;
right: 24px;
transition: left 250ms ease-in-out, right 250ms ease-in-out 50ms, background-color 250ms ease-in-out;
border-radius: 8px;
background-color: #4680fe;
box-shadow: 0 3px 6px rgba(70, 128, 254, 0.5);
}
<div class="toggle toggle--checked">
<input type="checkbox" class="input--hidden" checked>
<div class="input__row">
<div class="toggle__container">
<div class="toggle__track">
<span class="toggle__circle"></span>
<div class="toggle__handler"></div>
</div>
</div>
</div>
</div>
</div>

最佳答案

添加 background-color.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track 应该能够解决间隙问题,因为它没有改变你的效果尽可能。

.toggle {
display: inline-block;
position: relative;
overflow: visible;
height: auto;
width: 100%;
cursor: pointer;
}

.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track {
border-color: #4680fe;
background-color: #4680fe;
transition: background-color 250ms ease;
}
.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track .toggle__circle {
transform: translate(0, 0);
}
.toggle input[type=checkbox]:checked + .input__row .toggle__container .toggle__track .toggle__handler {
transition: left 250ms ease-in-out 50ms, right 250ms ease-in-out, background-color 250ms ease-in-out;
left: 24px;
right: 0;
background-color: white;
}

.input--hidden {
position: absolute;
left: 0px;
cursor: inherit;
pointer-events: all;
opacity: 0;
width: 100%;
height: 100%;
z-index: 1;
padding: 0px;
margin: 0px;
}

.input__row {
position: relative;
display: flex;
width: 100%;
height: 100%;
}

.toggle__container {
display: flex;
flex-shrink: 0;
position: relative;
box-sizing: border-box;
}

.toggle__track {
width: 100%;
height: 100%;
overflow: hidden;
position: relative;
box-sizing: border-box;
border-radius: 12px;
transition: border 250ms 0ms linear;
background-color: transparent;
box-shadow: 0 1px 1px rgba(70, 128, 254, 0.1);
border: 2px solid rgba(70, 128, 254, 0.4);
}

.toggle__circle {
display: block;
position: absolute;
top: -2px;
left: -2px;
transform: translate(-100%, 0);
transition: transform 250ms 0ms cubic-bezier(0.165, 0.84, 0.44, 1);
border-radius: 12px;
background-color: #4680fe;
}

.toggle__container,
.toggle__circle {
width: 48px;
height: 24px;
}

.toggle__handler {
position: absolute;
top: 0;
left: 0;
height: 16px;
margin: 2px;
right: 24px;
transition: left 250ms ease-in-out, right 250ms ease-in-out 50ms, background-color 250ms ease-in-out;
border-radius: 8px;
background-color: #4680fe;
box-shadow: 0 3px 6px rgba(70, 128, 254, 0.5);
}
<div class="toggle toggle--checked">
<input type="checkbox" class="input--hidden" checked>
<div class="input__row">
<div class="toggle__container">
<div class="toggle__track">
<span class="toggle__circle"></span>
<div class="toggle__handler"></div>
</div>
</div>
</div>
</div>

关于html - 切换按钮边框空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56471529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com