[英]CSS gradients vs background Image?
Some years ago, I've seen a lot of CSS codes using background-image: url(xxx.png)
simulating a gradient background filter, since only (please, correct if I'm wrong here) IE proprietary filter would provide CSS gradient. 几年前,我见过很多CSS代码使用
background-image: url(xxx.png)
模拟渐变背景滤镜,因为只有(请纠正,如果我错了)IE专有滤镜会提供CSS渐变。
Nowadays - keeping in mind the most used browsers today and portable devices browsers (smartphones/tablets), should I use: 如今 - 请记住当今最常用的浏览器和便携式设备浏览器(智能手机/平板电脑),我应该使用:
OR 要么
? ?
And how about IE9 issue there I have seen in some CSS gradient generators (ie collorzilla)? 我在一些CSS梯度生成器(即collorzilla)中看到IE9问题怎么样?
UPDATE: sorry I wasn't very clear.. my question is not "how to do that", is about wich is more efficient , acceptable or the correct way . 更新:抱歉,我不是很清楚..我的问题不是“如何做到”,而是更高效 , 可接受或正确的方式 。 thanks!
谢谢!
Here is a very sensitive issue. 这是一个非常敏感的问题。 In the company where I work, we did some research based on our customers and the views of their sites.
在我工作的公司,我们根据客户和他们网站的观点进行了一些研究。 The conclusion was: there are many users of IE8.
结论是:IE8有很多用户。
There are several ways to make the gradient css work in ie, one of the best I know is css3 pie: css3pie 有几种方法可以使渐变css工作,即我所知道的最好的一种方法是css3 pie: css3pie
However, an image format fillet, with a pixel width or height weighs almost inconsiderable, the only concern is that it generates a requisition more. 但是,像素宽度或高度的图像格式圆角的重量几乎是微不足道的,唯一的问题是它会更多地生成请购单。
So my opnion in my case was to use the css3pie ... it will probably work on smartphones as well. 所以我的意见是使用css3pie ......它也可能适用于智能手机。
Sorry for bad english. 抱歉英文不好。
So I had this same question myself, hoping to find the best solution with regards to performance, and I had come to the following conclusions: 所以我自己也有同样的问题,希望找到关于性能的最佳解决方案,我得出以下结论:
Pro Gradient: Pro Gradient:
Pro Image: 专业形象:
Those are the factors that I could come up with, hopefully I didn't leave anything big out. 这些是我能想到的因素,希望我没有留下任何重大的东西。 As for the direction I went, I tend to end up using gradients, for the aforementioned flexibility.
至于我走的方向,我倾向于最终使用渐变,以获得前面提到的灵活性。 Bandwidth was also somewhat of a concern, as I regularly have users in these remote areas with shotty reception.
带宽也有点令人担忧,因为我经常在这些偏远地区接待用户。
You could do what HTML5 Boilerplate does: 您可以执行HTML5 Boilerplate所做的事情:
<!DOCTYPE html>
<!--[if lt IE 7]><html class="lt-ie10 lt-ie9 lt-ie8 lt-ie7"><![endif]-->
<!--[if IE 7]> <html class="lt-ie10 lt-ie9 lt-ie8"><![endif]-->
<!--[if IE 8]> <html class="lt-ie10 lt-ie9"><![endif]-->
<!--[if IE 9 ]> <html class="lt-ie10"><![endif]-->
<!--[if gt IE 9]><!--> <html class=""><!--<![endif]-->
Now you have a <html>
with classes for IE: 现在你有了一个带有IE类的
<html>
:
IE6 --> lt-ie10, lt-ie9, lt-ie8, lt-ie7 IE6 - > lt-ie10,lt-ie9,lt-ie8,lt-ie7
IE7 --> lt-ie10, lt-ie9, lt-ie8, IE7 - > lt-ie10,lt-ie9,lt-ie8,
IE8 --> lt-ie10, lt-ie9 IE8 - > lt-ie10,lt-ie9
IE9 --> lt-ie10 IE9 - > lt-ie10
And in your CSS: 在你的CSS中:
.element { background-image: /*Your CSS3 gradient declaration */; }
.lt-ie10 { background-image: url(/*Your PNG file*/); }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.