SVG开篇

2020-01-30  本文已影响0人  David_Rao

什么是SVG?

如何编写SVG

  1. 方式1,在html文件中直接编写
<svg width="500" height="500">
    <circle cx="100" cy="100" r="50" fill="transparent" stroke="#000"></circle>
</svg>
  1. 方式2:通过浏览器直接打开svg文件
    html是一种特殊的xml,svg是xml格式,要被浏览器打开svg文件,需要在svg文件中的svg标签中加上这句话:xmlns = "http://www.w3.org/2000/svg"
// 在circle.svg文件中
<svg width="500" height="500" xmlns = "http://www.w3.org/2000/svg">
    <circle cx="100" cy="100" r="50" fill="transparent" stroke="#000"></circle>
</svg>
  1. 方式三:使用img标签引用
<img src="circle.svg">
  1. 方式四:作为css背景使用
<style>
    div{
        width: 500px;
        height: 500px;
        background: url("circle.svg");
    }
</style>
上一篇 下一篇

猜你喜欢

热点阅读