简体   繁体   English

嵌入式SVG-如何将image.svg放到页面上

[英]Inline SVG - How to Put an image.svg onto a Page

I'm only new to Inline SVG and from my reading it sounds really interesting. 我只是Inline SVG的新手,从我的阅读中听起来确实很有趣。 I expecially like the way it can maintain multiple colors (which are currently lost ith icon fonts). 我特别喜欢它可以保持多种颜色的方式(当前已丢失图标字体)。

Following is an graphic created in Adobe Illistrator and exported as an SVG: 以下是在Adobe Illistrator中创建并导出为SVG的图形:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="265.427px" height="105.59px" viewBox="0 0 265.427 105.59" enable-background="new 0 0 265.427 105.59"
     xml:space="preserve">
<g id="Edit_Button_1_">
    <linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="132.7144" y1="10.8496" x2="132.7144" y2="90.4107">
        <stop  offset="0.099" style="stop-color:#F5F6F6"/>
        <stop  offset="0.8267" style="stop-color:#E9E9E9"/>
    </linearGradient>

        <rect x="0.474" y="0.474" fill="url(#SVGID_1_)" stroke="#CDCCCC" stroke-width="0.9479" stroke-miterlimit="10" width="264.479" height="104.643"/>
    <g>
        <g>
            <g>
                <g>
                    <polygon fill="#6F6F6F" points="27.945,62.067 20.953,83.479 42.234,76.368                   "/>
                </g>
                <g>
                    <path fill="#6F6F6F" d="M67.206,22.81c3.765-3.827,9.988-3.805,14.024,0.166c4.024,3.969,4.154,10.186,0.39,14.013
                        L67.206,22.81z"/>
                </g>
                <polygon fill="#6F6F6F" points="45.999,72.609 31.698,58.312 62.865,27.153 77.16,41.45               "/>
            </g>
        </g>
    </g>
    <text transform="matrix(1 0 0 1 100.8813 74.3232)" fill="#6F6F6F" font-family="'Verdana'" font-size="57.8802">EDIT</text>
</g>
</svg>

I'm confussed on how to put this onto a HTML page. 我对如何将其放到HTML页面上感到困惑。 Do I just copy the <svg> to </svg> tags? 我是否只将<svg>复制到</svg>标签?

Is there any conversion/optimisation required? 是否需要任何转换/优化?

I've also read about defining SVG Files for later use: http://css-tricks.com/svg-sprites-use-better-icon-fonts/ 我还阅读了有关定义SVG文件供以后使用的信息: http : //css-tricks.com/svg-sprites-use-better-icon-fonts/

What are the advantages/disadvantages of this? 这有什么优点/缺点?

thankyou so much!! 非常感谢!!

Yes. 是。 You only need to copy the <svg> section. 您只需要复制<svg>部分。 The XML pre-amble lines ( <?xml> and <!DOCTYPE> ) are not required. 不需要XML前导行( <?xml><!DOCTYPE> )。

Demo here 在这里演示

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

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