【发布时间】:2023-01-07 20:04:42
【问题描述】:
我有一个这个类的 div:
<div class="hero-section width-80%"> A Hero Image </div>
CSS:
<style>
.width-80%{
max-width: 80%;
}
</style>
是否允许在类值中使用百分号?如果我想使用带有“%”符号的任何百分比类,如何在 css 中使用百分号?
【问题讨论】:
标签: css
我有一个这个类的 div:
<div class="hero-section width-80%"> A Hero Image </div>
CSS:
<style>
.width-80%{
max-width: 80%;
}
</style>
是否允许在类值中使用百分号?如果我想使用带有“%”符号的任何百分比类,如何在 css 中使用百分号?
【问题讨论】:
标签: css
是的,你必须在你的选择器中escape它:
.width-80% {
max-width: 80%;
color: red;
}
<div class="hero-section width-80%">A Hero Image</div>
【讨论】:
尝试这个:
.width-80% {
max-width: 80%;
}
【讨论】:
[class="width-80%"]?