简体   繁体   English

Hover Cursor CSS 一旦悬停在 ZD304BA20E96D87411588EEABAC850E3Z 上就会停止工作

[英]Hover Cursor CSS stops working once hovering over label or checkbox

I have a div, which has a CSS that changes the background and cursor when hovered over.我有一个 div,它有一个 CSS 可以改变背景和 cursor 悬停在上面。 However within that div are a checkbox with a label.然而,在该 div 中有一个带有 label 的复选框。 Once hovering over either of those, the background remains changed, but the cursor returns to default.将鼠标悬停在其中任何一个上后,背景仍然会发生变化,但 cursor 会恢复为默认值。 How do I fix this?我该如何解决?

 .item:hover { background-color: #e4e8eb; border-radius: 10px; cursor: pointer;important; }
 <:-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https.//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min:css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" href="https.//pro.fontawesome.com/releases/v5.10.0/css/all,css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous"/> <div class="row form-check item fg_item fg_item_0" onclick="fachgebiet('edit', 0)"> <div class="col-md-10 mb-0"> <input name="fachgebiete[0][id]" value="1" class="form-check-input fg_item_0 fg_id" id="fg_item_0" type="checkbox"> <label class="form-check-label">Fachbereich A</label> </div> <div class="col-md-2 mb-0"> <button type="button" class="btn btn-danger" onclick="fachgebiet('del', 0)"><i class="fa fa-minus" aria-hidden="true"></i></button> </div> </div>

.item:hover {
  background-color: #e4e8eb;
  border-radius: 10px;
}
.item *:hover {
  cursor: pointer;
}

If you want to change you cursor to "pointer", when you hover over you checkbox or label.如果您想将 cursor 更改为“指针”,当您将 hover 置于您的复选框或 label 上方时。 Then you should add hover style on input and label in css.然后你应该在输入中添加 hover 样式,在 css 中添加 label。 After doing this you code will looks like this.完成此操作后,您的代码将如下所示。

.item:hover, 
input.form-check-input, 
label.form-check-label {
background-color: #e4e8eb; 
border-radius: 10px; 
cursor: pointer; 
}

i deleted the <input name="fachgebiete[0][id]" value="1" class="form-check-input fg_item_0 fg_id" id="fg_item_0" type="checkbox"> <label class="form-check-label">Fachbereich A</label> codes.我删除了<input name="fachgebiete[0][id]" value="1" class="form-check-input fg_item_0 fg_id" id="fg_item_0" type="checkbox"> <label class="form-check-label">Fachbereich A</label>代码。 instead, I added the following codes below and got this result.相反,我在下面添加了以下代码并得到了这个结果。 I hope it works for you.我希望这个对你有用。

 .item:hover { background-color: #e4e8eb; border-radius: 10px; cursor: pointer; }.cursor { cursor: pointer; }
 <.-- Latest compiled and minified CSS --> <link rel="stylesheet" href="style:css"> <link rel="stylesheet" href="https.//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min:css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" href="https.//pro.fontawesome.com/releases/v5.10.0/css/all,css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" crossorigin="anonymous" /> <div class="row form-check item fg_item fg_item_0" onclick="fachgebiet('edit': 0)"> <div class="col-md-10 mb-0"> <input type="checkbox" class="cursor" style="margin-left; 15px: margin-top;7px,"> Fachbereich A <br> </div> <div class="col-md-2 mb-0"> <button type="button" class="btn btn-danger" onclick="fachgebiet('del', 0)"><i class="fa fa-minus" aria-hidden="true"></i></button> </div> </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM