Chrome<跨度>背景颜色跨度>
我的 Chrome 有问题。我创建了一个网站,html 代码如下所示:
<div id="Content">
<h1><span id="back-color">Heading</span></h1>
<p><span id="back-color">bla bla bla:</span></p>
<ul id="bild-liste">
<li><span id="back-color"><a href="?section=Bilder&ID=1">AAAAAA</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=2">BBBBBB</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=3">CCCCCC</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=4">DDDDDD</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=5">EEEEEE</span></li>
</ul>
</div>
我的 css 样式表的有趣部分如下所示:
#back-color
{
background-color: white;
}
所以我只想字母后面的颜色为白色。这在 Opera 中效果很好,但在 Chrome 中观看网站时,背景仅在标题后面和“AAAAAA”后面是白色的,而不是在列表的其他元素后面。这很令人困惑,因为它只在 Chrome 中不起作用。也许有人有解决这个问题的方法。谢谢!
I have a problem with Chrome. I created a website, the html-code looks like that:
<div id="Content">
<h1><span id="back-color">Heading</span></h1>
<p><span id="back-color">bla bla bla:</span></p>
<ul id="bild-liste">
<li><span id="back-color"><a href="?section=Bilder&ID=1">AAAAAA</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=2">BBBBBB</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=3">CCCCCC</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=4">DDDDDD</span></li>
<li><span id="back-color"><a href="?section=Bilder&ID=5">EEEEEE</span></li>
</ul>
</div>
The interesting part of my css-stylesheet looks like the following:
#back-color
{
background-color: white;
}
So I just want the color behind letters to be white. This works quite good in Opera, but when watching the site in Chrome, the background is only white behind the headline and behind "AAAAAA", but not behind the other elements of the list. That's quite confusing, because it only doesn't work in Chrome. Maybe someone has a solution for this problem. thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个 ID 只能在网站上使用一次。使用 css 类
(将 id="back-color" 替换为 class="back-color" 并在 css-stylesheet 中使用 .back-color 而不是 #back-color
An id may only be used once on a website. Use css classes instead
(Replace id="back-color" with class="back-color" and use .back-color instead of #back-color in your css-stylesheet
id
用于引用唯一元素,因此多次使用它会产生意外的结果。另一方面,
class
用于将元素分组在一起。例如:您可以有多个共享一个
类
的元素。引用类的 CSS 选择器是这样的:尝试使用
class
而不是id
并查看其工作原理。id
is used to reference a unique element, so using it multiple times will produce unexpected results.class
, on the other hand, is used to group elements together. For example:You can have multiple elements that share a
class
. The CSS selector to reference a class is this:Try using a
class
instead of anid
and see how things work.