body {
background-color:olive;
}
#container{
background-color:;
display:flex;
}
#container > a {
background-color:chocolate;
margin:5px;
padding:7px;
border-radius:10px;
}
#item-2 {
}
#item-4{
margin-left:auto;
}
#bonus {
background-color:red;
}
<body>
<nav>
<div id="container">
<a id="item-1 bonus" href="#">Information</a>
<a id="item-2 bonus" href="#">Contacts</a>
<a id="item-3 bonus" href="#">Media</a>
<a id="item-4" href="#">Logout</a>
</div>
</nav>
</body>
你好,谁能告诉我为什么“bonus”类不应用 background-color:red ?有没有规定不能放两个 id 什么的?一些澄清会非常有用。谢谢。
最佳答案
What are valid values for the id attribute in HTML?
阅读有关 HTML 属性 id
的内容。
您可以改为使用 class
属性在单个元素上使用多个类名。 id
不能这样使用。
关于html - 我一直在用两个 id 进行测试,第二个 id 没有做任何事情,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51395045/