本文介绍了什么时候考虑base64(DATA:URI)图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么因素应该引发考虑将图像切换到嵌入在CSS中的Base64?



似乎有很多通用的pro / con类型的东西那里。维基百科似乎有一个体面的概述:



根据我已经阅读的内容,似乎使base64轻松决定的一个因素是,如果你的网站必须访问很多个别的小图片,文件会更有效地击中服务器50次为每个单独的图像。



但是...它也似乎与sprite和事实,很少需要50



有一些关键因素我应该寻找(包括pro / con) ?




$ b

更新:



可能用更简洁的方式来表达这个问题:



给定这两个选项:



1)所有图像转换为base64并嵌入外部css文件



2)图像聚集成少量的sprite图像,在外部引用css文件



有没有明显的情况下,一个比另一个更好,或者是真的只是一个案件,做两个和测试类型的事情? / p>

解决方案




URIs不能大于32千字节。)



在这种情况下使用CSS sprites是非常优秀的技术。


What are the factors that should trigger thinking about switching images over to Base64 embedded in CSS?

There seems to be a lot of generic pro/con type things out there. Wikipedia seems to have a decent overview: http://en.wikipedia.org/wiki/Data_URI_scheme#Advantages

From what I've read, the one factor that seems to make base64 an easy decision would be if your site has to access a lot of individual small images and having one large file would be more efficient that hitting the server 50 times for each individual image.

But...it also seems that with sprites and the fact that rarely would I need 50 separate images on a page, Base64 isn't offering a whole lot for general web sites.

Are there are key factors I should be looking for (both pro/con)?

(This may better as a community wiki entry rather than question)

UPDATE:

Perhaps a more succinct way to word the question:

Given these two options:

1) All images converted to base64 and embedded in the external css file

2) Images gathered into a handful of sprite images, referenced in the external css file

Are there obvious situations where one is better than the other, or is it really just a case-by-case, do both and test type of thing?

解决方案

The biggest con is the missing support in IE6/7, and the incomplete support in IE8 (data: URIs must not be larger than 32 kilobytes there).

Using CSS sprites is the vastly superior technique in this case.

这篇关于什么时候考虑base64(DATA:URI)图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:40