我想滾動SVG文件使用IMG/1.png圖像的HTML ID標籤如何讓svg對象點擊鏈接?
我的HTML塊
<object width="1024" height="597" data="svg/index/1.svg" type="image/svg+xml" id="pdf1" style="width:1024px; height:597px; background-color:white; -moz-transform:scale(1); z-index: 0;">
</object>
我的SVG文件1.svg
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
<style type="text/css"><![CDATA[
.g1_1{
fill: #8FEFCA;
fill-opacity: 0.71000695;
}
.g2_1{
fill: #8EDBED;
fill-opacity: 0.5399929;
}
]]></style>
</defs>
<path d="M1024,597L0,597L0,320l1024,0l0,277Z" class="g1_1" />
<path d="M455,597l569,0L1024,0l-9,0Z" class="g2_1" />
<a xlink:href="#p2">
<image x="690" y="290" width="25" height="24" xlink:href="img/1.png" />
</a>
</svg>
我試着使用jquery裏面的svg文件,但我沒有在html文件中聲明的jquery滾動函數不叫
<div id = "p2"> scroll here </div>
現代瀏覽器可以在' '標籤。你有沒有試過,而不是使用'
'SVG's是自己的對象,'jquery'不能訪問它們的內部或者計算它們中的'offset'。你可以嘗試使用純JavaScript,但我懷疑這是行不通的,因爲SVG中的元素與viewbox,svg的大小等相比是偏移的。SVG不應該用於此目的。 – somethinghere
這裏是測試網址:http://cabitsystems.com/svgtest/tt.html雅我用對象 –