css - CSS隐藏属性内容
问题描述
预期结果
如果内容为 0,我想隐藏 data-count-green 的内容。
我试过使用以下
CSS
.myclass[data-count][content='0'] {
display: none;
}
HTML
<!DOCTYPE html>
<html>
<head>
<style>
.myclass[data-count] {
position: relative;
}
.myclass[data-count][content='0'] {
display: none;
}
.myclass[data-count]:after {
position: absolute;
content: attr(data-count);
}
</style>
</head>
<body>
<div>
<div>
<i class='myclass' id="comment" data-count='0' </i>
</div>
</div>
</body>
</html>
解决方案
只需使用.far[data-count-green='0']
.far[data-count-green='0'] {
display: none;
}
<div>
<div>
<i class='far' id="comment" data-count-green='0'>I'm not visible</i>
</div>
</div>
推荐阅读
- python - 如何在 Python 中使用数组输入用户的字符列表
- node.js - 有没有办法在 JSdoc 中指定通配符导出?
- jquery - 如何解决网站自动放大问题?
- tensorflow - tf.layers.Conv1D 与 tf.keras.layers.Conv1D
- html - 未从 Angular 7 中的 Firebase 检索数据
- javascript - 不能将 Chai.js 中的期望与 Nightwatch 一起使用
- javascript - 通过 id 更改表内的值
- node.js - TypeError:使用 findOneAndRemove() 时无法读取未定义的属性“_id”
- c# - (datatype, datatype) x = (value, value) 在 C# 中是什么意思?x 的实际数据类型是什么?
- android - Rxjava - 用批处理迭代列表