Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 悬停时更改SVG图像颜色_Html_Css_Svg - Fatal编程技术网

Html 悬停时更改SVG图像颜色

Html 悬停时更改SVG图像颜色,html,css,svg,Html,Css,Svg,我将直接讨论这个问题。我有一张代表葡萄牙的SVG地图。所以我想要的是:当我在里斯本的一个地区上空盘旋时,它会改变颜色。现在所有的区域都是灰色的,我希望只有当我在它们上面盘旋时它们才是橙色的 我考虑连接/调用一个css文件,为每个地区运行a:hover{color:orange;}代码。然而,它没有起作用。 为什么我不能用一个内胎 现在我在我的葡萄牙svg上有以下代码: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <

我将直接讨论这个问题。我有一张代表葡萄牙的SVG地图。所以我想要的是:当我在里斯本的一个地区上空盘旋时,它会改变颜色。现在所有的区域都是灰色的,我希望只有当我在它们上面盘旋时它们才是橙色的

我考虑连接/调用一个css文件,为每个地区运行a:hover{color:orange;}代码。然而,它没有起作用。 为什么我不能用一个内胎

现在我在我的葡萄牙svg上有以下代码:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet idhref="mystyle.css" type="text/css"?>
<html>
<svg

   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:xlink="http://www.w3.org/1999/xlink"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
   baseprofile="tiny"
   height="435.27365"
   version="1.2"
   viewbox="0 0 1000 597"
   width="431.70035"
   id="svg25"
   sodipodi:docname="Portugal.svg"
   style="fill:#7c7c7c;stroke:#ffffff;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"
   inkscape:version="0.92.1 r15371"
   xmlns:style="http://www.w3.org/TR/SVG/mystyle.css">

  <a xlink:href="http://www.artiroots.pt/devel-230b433e/wordpress/?s=Setubal">
        <title>Setúbal</title>
        <g>
        <path

            d="259......."
            id="P....."
            name="Setúbal"
            fill="#7c7c7c"
            inkscape:connector-curvature="0" 
            style="stroke-width: 0.100"
        />
        </g>
  </a>
</svg>
</html>

谢谢你的帮助,我真的很感激

SVG和HTML没有太大区别,因此您可以用类似的方式来处理它们

我在您的标记上看到的第一件事是,您在SVG代码中嵌入了fill属性,如果您只想使用CSS更改颜色,那么您将使用important!如果使用CSS设置svg的样式会更好,那么可以使用伪类hover来更改颜色

路径{ 填充:ccc; } 路径:悬停{ 馅料:番茄; } 映射svg
“我对此有很多问题,我搜索了很多,但我不知道该怎么做。”-这不是在这里工作的好基础。首先,请去阅读。然后告诉我们你的研究发现了什么不,那不可能是“什么都没有”,以及你用什么尝试了哪些结果。所以我必须创建一个example.css文件。正当这样我就可以插入路径{fill:ccc;}。。。。。。或者我应该将它直接插入svg文件中?这是推荐的方法,但是如果您只需要它,您可以将它放在同一页面上,并用样式标记包围。