使用CSS3

时间:2016-01-08 12:17:59

标签: html5 css3 svg webkit mask

我正在尝试应用CSS Mask来双向水平淡化DIV。 我使用在线编辑器创建了蒙版,它使用-webkit-mask和base64编码顺利运行:

#slicenter{-webkit-mask: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA+gAAAAUCAYAAAAeGxcbAAACWUlEQVR4Xu3bQU4DMQwFUHoH4P7ng94BGkSlyKQjRv6bqG8kVKVgd/rqjflwefl7vZWnxvly+/r6fXwt59XP31u8T3WjfnWeX672Olu/eDueIkCAAAECBAgQIECAAIEnEvgse+i1nMf352t1vu+/4/GovtZ+lH15dX742mPxrtfZpfhoqT6zzI/76Pwy4InmzVslQIAAAQIECBAgQIAAgQcC0aX59hpHS3dy2f9JxuslQTfnBAgQIECAAAECBAgQILCrgAR9+uTmBF6CvutIu28CBAgQIECAAAECBAjsKSBBnz63OYFP/rn8f/6Hfc/xcdcECBAgQIAAAQIECBAgkBKQoEvQU7OkDwECBAgQIECAAAECBAg0BCToEvTG+CglQIAAAQIECBAgQIAAgZSABF2CnpolfQgQIECAAAECBAgQIECgISBBl6A3xkcpAQIECBAgQIAAAQIECKQEJOgS9NQs6UOAAAECBAgQIECAAAECDQEJugS9MT5KCRAgQIAAAQIECBAgQCAlIEGXoKdmSR8CBAgQIECAAAECBAgQaAhI0CXojfFRSoAAAQIECBAgQIAAAQIpAQm6BD01S/oQIECAAAECBAgQIECAQENAgi5Bb4yPUgIECBAgQIAAAQIECBBICUjQJeipWdKHAAECBAgQIECAAAECBBoCEnQJemN8lBIgQIAAAQIECBAgQIBASkCCLkFPzZI+BAgQIECAAAECBAgQINAQkKBL0Bvjo5QAAQIECBAgQIAAAQIEUgISdAl6apb0IUCAAAECBAgQIECAAIGGwLYJ+jfSylgzQ2my8wAAAABJRU5ErkJggg==);}

问题是:这只适用于Chrome(也许是Safari)。

所以我尝试将同一图像导出为HTML / SVG。这就是我得到的:

<svg xmlns="http://www.w3.org/2000/svg" width="200px" height="200px" >
<defs> 
<linearGradient id="lgrad" x1="0%" y1="50%" x2="100%" y2="50%" > 
<stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
<stop offset="5%" style="stop-color:rgb(0,0,0);stop-opacity:1" />
<stop offset="95%" style="stop-color:rgb(0,0,0);stop-opacity:1" />
<stop offset="100%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
</linearGradient> 
</defs>
<rect x="0" y="0" width="100%" height="100%" fill="url(#lgrad)"/>
</svg>

然后我尝试在掩码中转换此向量(但这可能是错误的):

	<svg height="0" >
	<defs>
		<linearGradient id="g" gradientUnits="objectBoundingBox" x1="0%" y1="50%" x2="100%" y2="50%" > 
			<stop offset="0%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
			<stop offset="5%" style="stop-color:rgb(0,0,0);stop-opacity:1" />
			<stop offset="95%" style="stop-color:rgb(0,0,0);stop-opacity:1" />
			<stop offset="100%" style="stop-color:rgb(0,0,0);stop-opacity:0" />
		</linearGradient> 
		<mask id="lgrad" maskUnits="objectBoundingBox" maskContentUnits="objectBoundingBox"> 
			<rect x="0" y="0" width="100%" height="100%" fill="url(#g)"/>
		</mask>
	</defs>
	</svg>

我将遮罩应用于同一个元素:

#slicenter{mask: url(#lgrad);}

但它不起作用。有任何想法吗? 干杯

0 个答案:

没有答案