gpt4 book ai didi

html - 通过 CSS 使输入不可见但可点击?

转载 作者:太空狗 更新时间:2023-10-29 15:30:05 24 4
gpt4 key购买 nike

有什么方法可以仅通过 CSS 使 input radio 不可见吗?

我有以下布局:http://jsfiddle.net/t87k5k8u/2/

<label class="main">
<input name="rad-1" type="radio" checked=""/>
<div></div>
</label>
<label class="main">
<input name="rad-1" type="radio" />
<div></div>
</label>
<label class="main">
<input name="rad-1" type="radio" />
<div></div>
</label>

如您在示例中所见, radio 显示在顶部。我怎样才能使它出现在背面并且可以点击,或者甚至隐藏它同时让它可以点击?

最佳答案

opacity: 0 添加到 input 可能是一个开始。不确定浏览器支持,但它似乎适用于最新版本的 Firefox、Chrome 和 Safari。

.main {
position: relative
}
.main > div {
width: 200px;
height: 200px;
background: #f00;
}
input {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
opacity: 0;
}
input:checked + div {
background: #000
}
<div class="main">
<input type="checkbox" />
<div></div>
</div>

关于html - 通过 CSS 使输入不可见但可点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27564251/

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