gpt4 book ai didi

css - Bootstrap 4 游标,用于处于禁用状态的自定义控件

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

我需要其他光标来禁用自定义控件元素(复选框、单选按钮)

这种风格不起作用:

.custom-control-input:disabled ~ .custom-control-label::before {
cursor: not-allowed;
}

最佳答案

对于 Bootstrap 4 中禁用的自定义控件元素(复选框、单选按钮),您需要以下选择器 css 规则/选择器:

.custom-control-input:disabled ~ .custom-control-label {
cursor: not-allowed;
}

如果您只想为实际的复选框/单选按钮而不是标签使用自定义光标样式(在这种情况下不推荐),那么您需要这条规则:

.custom-control-input:disabled ~ .custom-control-label::after {
cursor: not-allowed;
}

单击下面的“运行代码片段”以查看它的运行情况:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

<style>
.custom-control-input:disabled~.custom-control-label {
cursor: not-allowed;
}
</style>

<form class="m-3">
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="customRadioInline1" name="customRadioInline1" class="custom-control-input">
<label class="custom-control-label" for="customRadioInline1">This custom radio is OK</label>
</div>
<div class="custom-control custom-radio custom-control-inline">
<input type="radio" id="customRadioInline2" name="customRadioInline1" class="custom-control-input" disabled>
<label class="custom-control-label" for="customRadioInline2">This one is disabled</label>
</div>

<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck1">
<label class="custom-control-label" for="customCheck1">This custom checkbox is OK</label>
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheck2">
<label class="custom-control-label" for="customCheck2">OK too</label>
</div>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customCheckDisabled" disabled>
<label class="custom-control-label" for="customCheckDisabled">This custom checkbox is disabled</label>
</div>

</form>

关于css - Bootstrap 4 游标,用于处于禁用状态的自定义控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49196847/

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