Html 使用ID设置背景色

Html 使用ID设置背景色,html,css,svg,background-color,Html,Css,Svg,Background Color,我的网页中有多个图表,我想将一个特定图表的背景颜色更改为白色,为此我使用了以下css样式 svg g:first-of-type rect { fill-opacity: 0; } svg g:first-of-type path { stroke: #e6e6e6; } svg g:first-of-type rect:not(:last-child) { fill: #ffffff; } 使用上面的代码,我的应用程序中的所有图表颜色都变为白色,如何将其应用于特定图表。在声明样式

我的网页中有多个图表,我想将一个特定图表的背景颜色更改为白色,为此我使用了以下css样式

svg g:first-of-type rect {
  fill-opacity: 0;
}
svg g:first-of-type path {
  stroke: #e6e6e6;
}
svg g:first-of-type rect:not(:last-child) {
  fill: #ffffff;
}
使用上面的代码,我的应用程序中的所有图表颜色都变为白色,如何将其应用于特定图表。在声明样式时,我尝试在svg元素前面使用div id值,但不起作用

<body>
  <div ng-controller="myController">
    <div id="chartOne" google-chart chart="myChart"></div>
  </div>

  <br>
   <div ng-controller="myController2" class="scnd">
    <div id="chartTwo" google-chart chart="myChart"></div>
  </div>

</body>
你写的风格也不正确

background-Color: 'none'
background-Color: 'transparent'

使用父div的id。 希望这有帮助

/*要将图表2中显示的灰色变为白色吗*/ /*svg g:rect类型的第一个{ 填充不透明度:0; } svg g:路径类型的第一个{ 行程:E6; } svg g:rect:not:last child类型的第一个{ 填充:ffffff; }*/ 图表二{ 背景色:红色; }
正如你的采摘者所说,你正在为两个图表使用不同的id,那么为什么不使用特定的图表id来应用css呢

backgroundColor设置为none或transparent在svg中不起作用,因为颜色来自svg fill属性

#chartTwo svg g:first-of-type rect {
  fill-opacity: 0;
}

#chartTwo svg g:first-of-type path {
  stroke: #e6e6e6;
}

#chartTwo svg g:first-of-type rect:not(:last-child) {
  fill: #ffffff;
}
用CSS试试这个


使用!重要信息:它会起作用。

你的风格都不正确。除非它不是CSS,它应该是背景色,都是小写。是的。我同意你的观点,但是CSS不区分大小写,它可以接受大写和小写
#chartTwo svg g:first-of-type rect {
  fill-opacity: 0;
}

#chartTwo svg g:first-of-type path {
  stroke: #e6e6e6;
}

#chartTwo svg g:first-of-type rect:not(:last-child) {
  fill: #ffffff;
}
background-color: none !important;

background-color: transparent !important;