gpt4 book ai didi

html - 在具有边框半径的 div 外部单击时单击触发器

转载 作者:行者123 更新时间:2023-11-28 10:35:00 24 4
gpt4 key购买 nike

我有以下代码来实现切换按钮。问题是,如果我单击切换按钮外的左上角或左下角(仍在边界矩形内),则会触发单击或检查操作,就好像它是一个矩形一样。奇怪的是,这只发生在左侧而不是右侧。

如何阻止这一切?

( 要重现问题,请单击切换开关的左上角或左下角 )

.switch {
position: relative;
display: inline-block;
width: 40px;
height: 34px;
}
.switch input {
display: none;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 20px;
width: 20px;
left: 3px;
bottom: 3px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2ECC71;
}
input:focus + .slider {
box-shadow: 0 0 1px #2ECC71;
}
input:checked + .slider:before {
-webkit-transform: translateX(25px);
-ms-transform: translateX(25px);
transform: translateX(25px);
}
/* Rounded sliders */

.slider.round {
border-radius: 34px;
height: 25px;
width: 50px;
}
.slider.round:before {
border-radius: 50%;
}
<label class="switch">
<input type="checkbox">
<div id="utm-parameters-control" class="slider round accordion-control"></div>
</label>

最佳答案

您可以使用 class="switch" 从标签中删除 widthheight。这应该可以解决问题:

.switch {
position: relative;
display: inline-block;
/* width: 40px; */
/* height: 34px; */

关于html - 在具有边框半径的 div 外部单击时单击触发器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38794081/

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