我想用包含 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/