<分区>
关闭 5 年前。
- 编辑问题以包含 desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem .这将有助于其他人回答问题。
- 这个问题是由于打字错误或无法再重现的问题引起的。虽然类似的问题可能是on-topic在这里,这个问题的解决方式不太可能帮助 future 的读者。
<分区>
关闭 5 年前。
我正在关注 YouTube 上关于如何自定义表单的复选框 ( https://youtu.be/ojWA8pdT-zY?t=5m58s ) 的教程,但我的 CSS 类无法被识别。不知道为什么。
这就是我在 HTML 中引用它的方式:
<label><input type="checkbox" name="check" value="1"/><span class="labeltext">1<span></label>
这就是我在 CSS 中得到它的方式:
.labeltext:before {
content: "hello";
}
我不确定我做错了什么。我已经可以在 Visual Studio Code 中看到它没有被识别,因为 .labeltext 的颜色没有像往常一样改变。
我试着让它成为一个 ID,看看是否能解决它,但没有成功。
感谢您花时间至少阅读我的问题!
编辑: 我意识到错别字了.. 哈哈。但在拼写错误修复后,它并没有解决我的问题。
EDIT2:我目前为止得到的整个 CSS。根据用户的建议
h1 {
font-family: sans-serif;
text-align: center;
}
p {
font-family: sans-serif;
}
h3 {
font-family: sans-serif;
}
label {
cursor: pointer;
}
input[type="checkbox"] {
display: none;
}
+.label-text:before {
content: "hello";
}
EDIT3: 解决了! CSS 中的 + 出于某种原因受到干扰。无论如何,它就像我现在想要的那样工作。感谢大家帮助我!
最佳答案
错别字
</span>
.labeltext:before {
content: "hello";
}
<label><input type="checkbox" name="check" value="1"/><span class="labeltext">1</span></label>
关于html - 我的 CSS 类无法被识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49350077/