无法使用“无"替代背景颜色,只能使用“继承"替代背景颜色. [英] Can't override background color with "none", only with "inherit"
问题描述
我试图从Windows 8 ListView控件中的.win-container元素(图块)中删除白色背景,以使背景完全显示出来.当我追踪样式时,我可以看到白色背景正按照以下规则应用...
I was trying to remove the white background from the .win-container elements (the tiles) in a Windows 8 ListView control to let the background show through. When I traced the styles, I could see that the white background was getting applied with the following rule...
.win-listview :not(.win-footprint).win-container
所以我为此写了自己的规则...
So I wrote my own rule for that like this...
.win-listview :not(.win-footprint).win-container {
background-color: none;
}
但这没用.
一个朋友帮我弄清楚我可以使用...
A friend helped me figure out that I could use...
.win-listview :not(.win-footprint).win-container {
background-color: inherit;
}
那很好.谁能告诉我世界上为什么会这样吗?
And that works great. Can anyone tell me why in the world this is so?
推荐答案
none
是 background-image
属性的值,而不是 background-color
.由于它不是 background-color
的有效值,因此该声明将被忽略,系统将继续使用默认的白色背景绘制您的图块.如果您想为瓷砖提供透明的背景,则需要使用 background-color:transparent
代替:
none
is a value of the background-image
property, not background-color
. Since it's not a valid value of background-color
, the declaration is ignored and the system will continue drawing your tiles with the default white background. If you want to give your tiles a transparent background, you need to use background-color: transparent
instead:
.win-listview :not(.win-footprint).win-container {
background-color: transparent;
}
(您也可以使用 background:none
,但是 none
再次表示 background-image
并隐含 transparent
表示 background-color
.)
(You can also use background: none
, but again none
represents background-image
with an implied transparent
for background-color
.)
背景色:继承
只是告诉您要使用的图块(或继承),其背景颜色与包含它们的 ListView
相同.这可能具有或可能没有明显的背景色的明显效果.但是,它与具有透明背景不同(除非 ListView
本身也具有透明背景,在您的情况下,它可能没有).
background-color: inherit
simply tells your tiles to take on (or inherit) the same background color as the ListView
containing them. This may or may not have an apparent effect of having no distinct background color. However it is not the same as having a transparent background (unless the ListView
itself also has a transparent background, which in your case it probably doesn't).
这篇关于无法使用“无"替代背景颜色,只能使用“继承"替代背景颜色.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!