對於一個項目,我們一直在使用SVG圖像。我想它們上色,但沒有成功,這裏的SVG:SVG顏色不變
<svg id="Calque_2" data-name="Calque 2" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 313.89 311.93">
<defs>
<style>
.cls-1 {
fill: #fff;
opacity: 0.3;
}
</style>
</defs>
<title>goutte_background</title><path
class="cls-1"
d="M1145.43,987.78c-45,0-81.7-35.18-82.09-79.35v-4.3h0a63.88,63.88,0,0,1,2-14.07,90.58,90.58,0,0,1,6.25-17.2c13.68-30.49,38.7-63.33,38.7-63.33,18.76-26.58,27.36-46.91,30.88-59.81a147.8,147.8,0,0,0-57.07,12.12,158.6,158.6,0,0,0-83.26,83.26,151.14,151.14,0,0,0-12.12,60.59c0,21.5,3.91,41.83,12.12,60.59a158.6,158.6,0,0,0,83.26,83.26c18.76,8.21,39.09,12.12,60.59,12.12h2c21.5,0,41.83-3.91,60.59-12.12a158.6,158.6,0,0,0,83.26-83.26c8.21-18.76,12.12-39.09,12.12-60.59a151.14,151.14,0,0,0-12.12-60.59,158.6,158.6,0,0,0-83.26-83.26,147.8,147.8,0,0,0-57.07-12.12c3.52,12.9,12.12,33.23,30.88,59.81,0,0,25,32.84,38.7,63.33a90.58,90.58,0,0,1,6.25,17.2,63.88,63.88,0,0,1,2,14.07h0v4.3c-0.39,44.17-37.14,79.35-82.09,79.35h-0.39Z"
transform="translate(-988.68 -749.72)"/><path
class="cls-1"
d="M1145.43,778.26l1.56,6.25c2,8.21,7.82,25.8,24.63,49.64,0,0,18.76,24.24,28.93,46.91a62.83,62.83,0,0,1,4.69,12.9,32.92,32.92,0,0,1,1.56,10.55h0v3.13c0,32.84-27.36,59-61,59h-0.39c-33.62,0-61-26.19-61-59v-3.13h0A32.93,32.93,0,0,1,1086,894a62.83,62.83,0,0,1,4.69-12.9c10.16-22.67,28.93-46.91,28.93-46.91,16.81-23.84,22.67-41.43,24.63-49.64Z"
transform="translate(-988.68 -749.72)"/></svg>
我目前使用這個SVG作爲一個div
背景,而我努力改變它的顏色。
這是我已經試過:
.someParent .CLS-1 { 填充:#0080FF重要;! }
和
.someParent svg {
fill: #0080FF !important;
}
我也一直在試圖移除SVG的style
但沒有效果。
這是使用SVG作爲我的div背景的CSS:
background: #ffffff url("../images/goutte_background.svg") no-repeat right top;
CSS不知道嵌套選擇器。我認爲'.someParent .cls-1 {/*...*/}'或'.someParent svg {/*...*/}'是你正在尋找的東西。 – Siguza
我的壞,我使用sass –
除非你有一個Sass-> CSS編譯問題,**只發布編譯後的CSS ** – cimmanon