Positioning SVG elements using CSS

后端 未结 7 1935
野性不改
野性不改 2020-12-29 01:14

Assume the following svg document:




        
7条回答
  •  孤独总比滥情好
    2020-12-29 01:57

    I came here looking for a fix but fixed the issue myself, thought I would share:

    transform: translate(100px, 100px)
    

    Appears to work in all modern browsers except for Internet Explorer, right up until Microsoft Edge (which isn't even out yet) which is quite disappointing. The elements I've tested on are:

    
    
    
    

    The only issue I've had is with elements, and the solution there is to wrap the in a and apply the transformation to that. That should also work for any elements I haven't yet tested that have issues with transform: translate().

    I haven't found a decent fallback for Internet Explorer, instead I've made sure that the transforms aren't vital to the function of the SVG.

提交回复
热议问题