--- title: opacity slug: Web/CSS/opacity tags: - CSS - CSS Property - Reference translation_of: Web/CSS/opacity ---
Parametr opacity ustala przezroczystość elementu, czyli stopień, w jakim są widoczne elementy za określonym elementem.
visual 0.0, 1.0])opacity: number | inherit ;
hbox.example {
opacity: 0.5; /* zobacz tło poprzez hbox */
}
pre { /* make the box translucent (20% nieprzezroczystości) */
border: solid red;
opacity: 0.2;
filter: alpha(opacity=20); /* IE8 i starsze */
zoom: 1; /* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */
}
pre { /* make the box translucent (50% nieprzezroczystości) */
border: solid red;
opacity: 0.5;
filter: alpha(opacity=50); /* IE8 i starsze */
zoom: 1; /* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */
}
pre { /* make the box translucent (80% nieprzezroczystości) */
border: solid red;
opacity: 0.8;
filter: alpha(opacity=80); /* IE8 i starsze */
zoom: 1; /* set "zoom", "width" or "height" to trigger "hasLayout" in IE 7 and lower */
}
<html>
<head>
<style>
img.opacity {
opacity: 1;
filter: alpha(opacity=50);
zoom: 1;
}
img.opacity:hover {
opacity: 0.5;
filter: alpha(opacity=100);
zoom: 1;
}
</style>
</head>
<body>
<img src="//developer.mozilla.org/media/img/mdn-logo.png" alt="MDN logo" width="128" height="146" class="opacity" />
</body>
</html>
{{ CompatibilityTable() }}
| Element | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Podstawowe wsparcie | 1.0 | {{ CompatGeckoDesktop("1.7") }} | 9.0 | 9.0 | 1.2 (125) |
8.0filter: alpha(opacity=xx)(oba to synonimy) |
|||||
4.0filter: alpha(opacity=xx) |
| Element | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Podstawowe wsparcie | 1.0 | {{ CompatGeckoMobile("1.7") }} | 9.0 | 9.0 | 3.2 |
8.0filter: alpha(opacity=xx)(oba to synonimy) |
|||||
4.0filter: alpha(opacity=xx) |
opacity, zamiast tego należało używać filter.progid:DXImageTransform.Microsoft.Alpha(Opacity=xx). This is needless, so don't use it.-ms-filter, jednak jest to synonim do filter. Nie używaj wersji z prefiksem.-moz-opacity, -khtml-opacity nie są wspierane od początku 2004 roku.opacity od wersji 4.0. Nie używaj więcej -khtml-opacity ani -moz-opacity.