小议Data URI scheme及其在CSS中的相关使用

2020-05-03 10:53:32易采站长站整理

解决这个问题的办法有:使用MHTML 解决 data URI scheme 的浏览器兼容问题

具体做法看代码(肯定是用css hack来实现)

CSS Code复制内容到剪贴板

/*  
Content-Type: multipart/related; boundary="_ANY_STRING_WILL_DO_AS_A_SEPARATOR"  
   
–_ANY_STRING_WILL_DO_AS_A_SEPARATOR  
Content-Location:the9  
Content-Transfer-Encoding:base64  
   
/9j/4AA….+b0//2Q== (这里是base64编码)  
*/  
    
#the9{   
  background-image: url("data:image/png;base64/9j/4AA….+b0//2Q=="); /* normal */  
  *background-image: url(mhtml:http://www.zhangjingwei.com/demo/scheme/style.css!the9);   
  width:300px;   
  height:300px;   
  color:#F00;   
  font-weight:900;   
}