Can't override background color with “none”, only with “inherit”

半世苍凉 提交于 2019-12-12 10:55:26

问题


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;
}

But that didn't work.

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?


回答1:


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;
}

(You can also use background: none, but again none represents background-image with an implied transparent for background-color.)

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).



来源:https://stackoverflow.com/questions/12148088/cant-override-background-color-with-none-only-with-inherit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!