我有一個文字和圖像並排放置,中間留有一點空白。我想繪製一個箭頭到圖像上的特定點。如何在svg響應中製作線條的位置
因此,我試圖使用svg
然而,該行的位置不知何故無法響應。在閱讀了幾個問題(如this)和博客帖子(如this)之後,我將所有值更改爲%
,並且還添加了viewBox
屬性。但出於某種原因,箭頭僅位於當前瀏覽器屏幕1920x1200的正確位置。如果我調整瀏覽器窗口的大小,箭頭位置不正確。我的代碼:
HTML:
<div id="a">
This is the nose
</div><svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%" viewBox="0 0 2000 2000" preserveAspectRatio="none">
<line x1="9%" y1="9.5%" x2="23%" y2="6%" marker-end="url(#triangle)" stroke="black" stroke-width="0.2%"/>
</svg>
<img src="http://www.hickerphoto.com/images/200/little-polar-bear_29287.jpg" />
CSS:
#a{
position: absolute;
margin-top: 8%;
}
svg{
position: absolute;
z-index:2;
}
img{
margin-left: 20%;
position:relative;
z-index:1;
}
下面是一個fiddle
任何一個想法,爲什麼這是不工作?
svg在這裏甚至是正確的嘗試還是應該使用別的東西?
能否請您解釋一下下降投票? – Tom