码迷,mamicode.com
首页 > 其他好文 > 详细

用SVG做background image

时间:2017-09-09 09:45:37      阅读:2782      评论:0      收藏:0      [点我收藏+]

标签:20px   gedit   stroke   point   res   style   reserve   pem   替换   

 

 

1 用utf8格式, 需要 双引号“”替换为单引号,而且采用url encode编码,例如# 替换为 %23,

body { background-image:
url("data:image/svg+xml;utf8,<svg xmlns=‘http://www.w3.org/2000/svg‘ xmlns:xlink=‘http://www.w3.org/1999/xlink‘ width=‘1060px‘ height=‘580px‘ viewBox=‘0 0 1060 580‘ preserveAspectRatio=‘xMidYMid meet‘ ><rect id=‘svgEditorBackground‘ x=‘0‘ y=‘0‘ width=‘1060‘ height=‘580‘ style=‘fill: none; stroke: none;‘/><rect x=‘115‘ y=‘111‘ stroke=‘black‘ id=‘e1_rectangle‘ style=‘stroke-width: 1px;‘ width=‘144‘ height=‘120‘ fill=‘khaki‘/><polyline stroke=‘black‘ stroke-width=‘1‘ id=‘e2_polyline‘ style=‘fill: none;‘ points=‘115 109 187 69 257 109‘ /><text fill=‘black‘ x=‘257‘ y=‘33‘ id=‘e4_texte‘ style=‘font-family: Arial; font-size: 20px;‘></text><rect x=‘179‘ y=‘19‘ stroke=‘black‘ id=‘e5_rectangle‘ style=‘stroke-width: 1px;‘ width=‘16‘ height=‘54‘ fill=‘khaki‘ /></svg>");
}

 


2 用base64格式, 把<svg>... </svg> 用btoa() 转换为base64编码

 

body { background-image:
url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iMTA2MHB4IiBoZWlnaHQ9IjU4MHB4IiB2aWV3Qm94PSIwIDAgIDEwNjAgNTgwIiBwcmVzZXJ2ZUFzcGVjdFJhdGlvPSJ4TWlkWU1pZCBtZWV0IiA+PHJlY3QgaWQ9InN2Z0VkaXRvckJhY2tncm91bmQiIHg9IjAiIHk9IjAiIHdpZHRoPSIxMDYwIiBoZWlnaHQ9IjU4MCIgc3R5bGU9ImZpbGw6IG5vbmU7IHN0cm9rZTogbm9uZTsiLz48cmVjdCB4PSIxMTUiIHk9IjExMSIgc3Ryb2tlPSJibGFjayIgaWQ9ImUxX3JlY3RhbmdsZSIgc3R5bGU9InN0cm9rZS13aWR0aDogMXB4OyIgd2lkdGg9IjE0NCIgaGVpZ2h0PSIxMjAiIGZpbGw9ImtoYWtpIi8+PHBvbHlsaW5lIHN0cm9rZT0iYmxhY2siIHN0cm9rZS13aWR0aD0iMSIgaWQ9ImUyX3BvbHlsaW5lIiBzdHlsZT0iZmlsbDogbm9uZTsiIHBvaW50cz0iMTE1IDEwOSAxODcgNjkgMjU3IDEwOSIgLz48dGV4dCBmaWxsPSJibGFjayIgeD0iMjU3IiB5PSIzMyIgaWQ9ImU0X3RleHRlIiBzdHlsZT0iZm9udC1mYW1pbHk6IEFyaWFsOyBmb250LXNpemU6IDIwcHg7Ij48L3RleHQ+PHJlY3QgeD0iMTc5IiB5PSIxOSIgc3Ryb2tlPSJibGFjayIgaWQ9ImU1X3JlY3RhbmdsZSIgc3R5bGU9InN0cm9rZS13aWR0aDogMXB4OyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjU0IiBmaWxsPSJraGFraSIgLz48L3N2Zz4=");

 

用绘制SVG 

http://www.drawsvg.org/drawsvg.html

 

用SVG做background image

标签:20px   gedit   stroke   point   res   style   reserve   pem   替换   

原文地址:http://www.cnblogs.com/GameEngine/p/7497070.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!