gpt4 book ai didi

html - 不能在 div 中设置样式元素?

转载 作者:太空宇宙 更新时间:2023-11-03 21:09:31 25 4
gpt4 key购买 nike

我想用包含 class="match"id="1" 设置 div 的样式代码:

<div class="col-lg-3">
<div id="1">
<p class="match">Match {this.state.matches[0].id}</p>
<div class="team1">
<h4>{this.state.matches[0].team1}</h4>
</div>
<div><h3 align="center">VS</h3></div>
<div class="team2">
<h4>{this.state.matches[1].team2}</h4>
</div>
</div>
</div>

每当我使用下面的代码时:

.match{
background-color: yellow;
}

但是当我像下面这样设置它时它不起作用,原因是:

#1 .match{
background-color: yellow;
}

我有多个 id=1,2,3,.. 的 div,每个都有 class="match"

最佳答案

根据您的 HTML 版本,

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

这是针对 HTML4 的。 HTML5 应该允许您首先使用数字。尝试使用非数字 ID?

关于html - 不能在 div 中设置样式元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48403032/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com