url引用格式:url('data:image/svg+xml;base64')
实例:
准备好SVG文件

源码:
1<!doctype html> 2<html lang="en"> 3<head> 4 <meta charset="UTF-8"> 5 <title>Document</title> 6</head> 7<style> 8 body{ /*base64代码--直接复制SVG文件里的所有代码*/ 9 background: rgb(255,255,255) url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='100' viewBox='0 0 200 100' preserveAspectRatio='none'><defs><radialGradient id='rg1' cx='0%' cy='0%' r='100%' fx='0%' fy='0%'><stop offset='0%' style='stop-color: #a480ff; stop-opacity: 0.5' /><stop offset='100%' style='stop-color: #a480ff; stop-opacity:0' /></radialGradient><radialGradient id='rg2' cx='100%' cy='0%' r='100%' fx='100%' fy='0%'><stop offset='0%' style='stop-color: #ff8f83; stop-opacity: 0.5' /><stop offset='100%' style='stop-color: #ff8f83; stop-opacity:0' /></radialGradient></defs><polygon points='0,0 125,0 125,100 0,100' style='fill: url(#rg1);' /><polygon points='75,0 200,0 200,100 75,100' style='fill: url(#rg2);' /></svg>") no-repeat; 10 -webkit-background-size: 100% auto; 11 background-size: 100% auto; 12 } 13</style> 14<body> 15</body> 16</html>
效果:
