html - CSS,HTML - 在检查输入时需要帮助更改子元素的文本并更改图标
问题描述
样式几乎完成了,但我还有一个问题。css 现在所做的是,它更改文本并更改图标,但将图标放在文本顶部,因为文本使用position: absolute
.
如何将图标保持在原位?
.an_radio input:checked+span+i:before {
position: relative;
content: "\f00c" !important;
}
.an_radio input:checked+span:before {
content: "toegevoegd";
visibility: visible;
}
.an_radio input:checked+span {
position: absolute;
visibility: hidden;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet" />
<div class="radio-inline an_radio" style="display: inline-block;">
<label class="top" style="min-width: 7px">
<input type="checkbox">
<span>voeg toe</span>
<i class="fas fa-shopping-cart"></i>
</label>
</div>
解决方案
更改一些 HTML
.an_radio input+span b {
font-weight: normal
}
.an_radio input:checked+span b {
display: none;
}
.an_radio input:checked+span:before {
content: "toegevoegd";
visibility: visible;
}
.an_radio input:checked+span i:before {
content: "\f00c" !important;
visibility: visible;
position: relative;
}
.an_radio input:checked+span {
position: absolute;
visibility: hidden;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.min.css" rel="stylesheet" />
<div class="radio-inline an_radio" style="display: inline-block;">
<label class="top" style="min-width: 7px">
<input type="checkbox" name="an_productfields_1[]" id="an_productfields_1_0" value="Basis servicepakket" class="Basis servicepakket" data-price="0" data-pricemain="0">
<span>
<b>voeg toe</b> <!-- Change Here -->
<i class="fas fa-shopping-cart"></i> <!-- Change Here -->
</span>
</label>
</div>
推荐阅读
- wordpress - 延迟加载 Wordpress 帖子
- apache-kafka - 通过 hdfs 连接器从 kafka 写入时,有没有办法限制 avro 文件的大小?
- azure - Azure SQL 数据库和 SQL Server PAAS - 为什么两者都需要?
- vue.js - vue 单元测试与 jest
- ios - 单击tableview行后如何导航到另一个视图
- sql - IBM DB2:具有多个连接的 SQL 查询
- android - 在颤振中使用地理编码器包时出错
- node.js - “assets”文件夹中的 Sails.JS 部分加载问题
- angular - 角度打印功能未显示输入内的文本和角度材料样式
- c++ - C++17 Using Class Template Argument Deduction 用于保存函数返回值的类型的指南