美文网首页
html中使用svg技巧

html中使用svg技巧

作者: 夏晶晶绿 | 来源:发表于2018-01-17 18:05 被阅读106次
    1.img标签引入

    <img src="picture.svg">
    chrome显示不全问题(有时会显示完整);IE,火狐,safari正常
    移动端缩放文字比例失调问题处理:
    svg文件中给所有的text标签加上text-rendering="geometricPrecision"

    2.使用css作为背景图片

    div{background:url("picture.svg") no-repeat center top;background-size:contain;}
    chrome显示不全问题(有时会显示完整),IE,火狐,safari显示正常;
    移动端缩放文字比例失调问题处理:
    svg文件中给所有的text标签加上text-rendering="geometricPrecision"
    缺点是不能根据svg背景图自适应大小

    3.object标签引入

    <object data="picture.svg" width="100%" height="100%" type="image/svg+xml" codebase="http://www.adobe.com/svg/viewer/imstall/" />
    chrome,IE9以上正常,火狐不显示,safari不能等比缩放出现滚动条
    移动端文字可以等比缩放

    4.embed标签引入

    <embed src="picture.svg" width="100%" height="100%" type="image/svg+xml" pluginspage="http://www.adobe.com/svg/viewer/install/" />
    chrome,IE,火狐正常;safari不能等比缩放出现滚动条
    移动端文字可以等比缩放

    同一个页面,object标签一定要放在最后,否则其之后的标签浏览器中不出现

    相关文章

      网友评论

          本文标题:html中使用svg技巧

          本文链接:https://www.haomeiwen.com/subject/ugvuoxtx.html