用SVG做background image
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+PHJlY3QgaWQ9InN2Z0VkaXRvckJhY2tncm91bmQiIHg9IjAiIHk9IjAiIHdpZHRoPSIxMDYwIiBoZWlnaHQ9IjU4MCIgc3R5bGU9ImZpbGw6IG5vbmU7IHN0cm9rZTogbm9uZTsiLz48cmVjdCB4PSIxMTUiIHk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