css - 当检查图标在输入(复选框)上正确时,它不会触发更改事件。我怎样才能解决这个问题?
问题描述
HTML是这部分
<div class="words">
<ng-container *ngFor="let word of words; let i = index">
<div class="word" [ngClass]="{'checked': checkbox.checked}">
<label for="word">{{ word }}
<input [id]="i" #checkbox type="checkbox" name="word" (change)="isChecked($event)"/>
</label>
</div>
</ng-container>
</div>
在css文件中我有这种风格
.words {
display: grid;
grid-template-columns: repeat(4, 100px);
grid-template-rows: repeat(2, 250px);
div {
width: 154px;
height: 58px;
border: 1.5px solid #7f33c9;
border-radius: 48px;
display: flex;
justify-content: center;
align-items: center;
input {
-webkit-appearance: none;
background: #efefef;
border-radius: 48px;
display: inline-block;
width: 36px;
height: 36px;
border: none;
position: relative;
top: 10px;
&:checked {
-webkit-appearance: none;
background-color: green;
}
}
}
}
.checked {
background-color: #732cb9;
label {
color: white;
&::after {
font-family: "Material Icons";
content: "done";
font-size: 35px;
position: relative;
top: 15px;
right: 37px;
width: 0px;
height: 0px;
}
}
}
当图标在复选框之外时,它会触发事件,但是当我将它定位为在复选框中时,它会影响它并且事件不会触发我该如何解决这个问题?
解决方案
推荐阅读
- c# - Wrong Enum index when serializing an Enum field (Unity)
- developer-tools - Firefox 开发者版在控制台中显示所有默认文档属性
- javascript - React JS如何在输入字段中显示密码5秒然后隐藏?
- python - 将“日期”数据转换为 datetime64[ns] 类型
- xml - 使用 vb.net 在 xml 中编辑标签参数
- reactjs - 单击nabber链接时React BrowserRouter不呈现
- python-3.x - 字典中的多个键
- python - 如何从 Python 中的文本中删除空行?
- python - 读取 csv 文件时时间序列预测中的值错误
- android - 如何在没有用户干预的情况下在(可能植根的)android 10 上以编程方式拨打电话