css - 关注带有 CSS 的输入隐藏标签
问题描述
我有这个表格:
<div class="c--input">
<label for="firstname">Firstname</label>
<input id="firstname" type="text">
</div>
我想删除<label>
当用户尝试在输入中插入文本时。
所以我用了这个:
.c--input input:focus + label::before,
.c--input input:active + label::before {
opacity: 0; /* To visually hide the label's pseudoelement */
pointer-events: none; /* To prevent any cursor-based interaction */
}
为什么它不起作用?
谢谢。
解决方案
请尝试此操作以通过显示无显示或激活隐藏并通过显示内联显示
.c--input label{
display: inline-block;
}
div input:active + label,
div input:focus + label {
display: none;
}
推荐阅读
- python - 从零开始的神经网络:只正确预测训练输入
- python-3.x - 使用glob查询文件的正确方法
- notepad++ - notepad ++中对齐和缩进换行之间的区别?
- c# - 如何在 UML 序列图中表示 c# setter?
- node.js - 如何将模型转换为 Mongoose 中的不同响应
- automated-tests - 如何从 @DataProvider 获取 @Before 中的 @Test 和 TestNG 中的 @AfterMethod 注释的参数值
- python - 如何将导出放在 shell 脚本中以包含 oracle 库
- python - Python Unittest - 模拟与补丁
- c++ - 擦除后C ++设置值突然改变?
- pip - 安装pip时如何处理'/usr/bin/python:没有名为pip的模块'?