CSS不透明属性? [英] CSS Opacity Properties?
问题描述
我真的需要所有这些CSS不透明属性吗?我不是一次使用所有这些,而是以不同的百分比显示它们。但我通常有4组,我想看看是否可以从我的样式表中消除任何东西。
Do I really need all these CSS Opacity Properties? I'm not using ALL of these at once, but showing them at different percentages. But I usually have the group of 4 and I wanted to see if I can eliminate anything from my stylesheet.
有人可以给我一个例子100%,25% ,0%。
And can someone show me an example of 100%, 25%, and 0%? I want to make sure I have them done correctly.
opacity: 1;
-moz-opacity: 1;
filter:alpha(opacity=1);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=100)";
opacity: 0.25;
-moz-opacity: 0.25;
filter:alpha(opacity=0.25);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=25)";
opacity: 0;
-moz-opacity: 0;
filter:alpha(opacity=0);
-ms-filter: "progid: DXImageTransform.Microsoft.Alpha(Opacity=0)";
}
推荐答案
尽可能多的浏览器,您需要所有这些属性:
If you want CSS3 opacity across as many browsers as possible, you'll need all of these properties:
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"; /*Best for Internet Explorer 8 */
filter: alpha(opacity=50); /*Internet Explorer 5, 6, 7, 8 */
-moz-opacity: 0.5; /* Old Mozilla Browsers */
-webkit-opacity: 0.5; /* Old Webkit browsers (Safari, Chrome, various others) */
-khtml-opacity: 0.5; /* Really old Safari browsers and Konqueror */
opacity: 0.5; /* Modern browsers */
但是,你可以削减大多数现代用途:
However, you can cut most of those for modern usage:
filter: alpha(opacity=50); /*Internet Explorer 5, 6, 7, 8 */
opacity: 0.5; /* Modern browsers */
请注意,虽然IE 8支持 code>,这不是推荐的方式添加不透明度。但是,一切都一样。
Note that while IE 8 support filter
, it's not the recommended way to add opacity. However, it all works the same.
这篇关于CSS不透明属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!