简体   繁体   English

调整浏览器大小时SVG图片中的链接消失

[英]Link in SVG image disappearing when resize browser

I am working on a clickable human body svg so visitors can click the part they injured and they will be directed to the corresponding page, there is way too much code for the svg to add here so ill just add the top section: 我正在研究可点击的人体svg,因此访客可以单击他们受伤的部分,然后将他们定向到相应的页面,因为svg的代码太多,无法在此处添加,所以请添加顶部:

<div class="svg">
<svg inkscape:version="0.92.3 (2405546, 2018-03-11)" 
 sodipodi:docname="bodynew.svg" version="1.1" viewBox="0 0 500 400" 
 xmlns="http://www.w3.org/2000/svg" 
 xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" 
 xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd">
 <sodipodi:namedview bordercolor="#666666" borderopacity="1" fit-margin- 
 bottom="0" fit-margin-left="0" fit-margin-right="0" fit-margin-top="0" 
 gridtolerance="10" guidetolerance="10" inkscape:current-layer="svg4523" 
 inkscape:cx="260.76197" inkscape:cy="215.76186" inkscape:pageopacity="0" 
 inkscape:pageshadow="2" inkscape:window-height="837" inkscape:window- 
 maximized="1" inkscape:window-width="1440" inkscape:window-x="-8" 
 inkscape:window-y="-8" inkscape:zoom="1.5571096" objecttolerance="10" 
 pagecolor="#ffffff" showgrid="false"/>
 <g>
 <a xlink:href="#0" class="svg" data-Name="shape 1" data-tabindex="0">

The css i am using is very straight forward, all it is doing is highlighting the links as the visitor hovers. 我正在使用的CSS非常简单,它所做的只是在访客徘徊时突出显示链接。

a.svg {
cursor: pointer;
}

a.svg:focus {
fill: pink;
stroke: red;
stroke-width: 1;
}
a.svg:hover {
fill: pink;
stroke: red;
stroke-width: 1;
}

This works just fine as expected but as soon as i change window size or move to mobile the links are no longer clickable so the hover capabilities are gone. 这可以按预期工作,但是一旦我更改窗口大小或移至移动设备,链接将不再可单击,因此悬停功能将消失。

any help with this would be greatly appreciated 任何帮助,将不胜感激

Thank you 谢谢

Well I don't know what the exact problem is, but it looks like Bootstrap is causing the top padding of the #pricing section to extend over the entire SVG. 好吧,我不知道确切的问题是什么,但是Bootstrap似乎导致#pricing部分的顶部填充扩展到整个SVG。

A quick fix would be to add the following CSS rule (after loading Bootstrap): 一个快速的解决方法是添加以下CSS规则(在加载Bootstrap之后):

#pricing .container .row:first-child { pointer-events: none; }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM