CSS Image Opacity - Transparency
CSS Image Opacity - Transparency
Search w3schools.c Select Language HOME HTML C SS JAVASC RIPT JQUERY XML ASP.NET PHP SQL MORE...
R EFER ENC ES | EXAMPLES
Get Certified
Study Web Technologies and get a diploma at w3schools.com
CSS Basic
CSS HOME CSS Introduction CSS Syntax CSS Id & Class CSS How To
Next Chapter
CSS Styling
Styling Backgrounds Styling Text Styling Fonts Styling Links Styling Lists Styling Tables Creating transparent images - Hover effect Creating a transparent box with text on a background image
CSS Advanced
CSS Grouping/Nesting CSS Dimension CSS Display CSS Positioning CSS Floating CSS Align CSS Pseudo-class CSS Pseudo-element CSS Navigation Bar CSS Image Gallery CSS Image Opacity CSS Image Sprites CSS Media Types CSS Attribute Selectors CSS Summary Look at the following CSS: The same image with transparency:
CSS Examples
CSS Examples CSS Quiz CSS Certificate
i m g { o p a c i t y : 0 . 4 ; f i l t e r : a l p h a ( o p a c i t y = 4 0 ) ;/ *F o rI E 8a n de a r l i e r* / }
IE9, Firefox, Chrome, Opera, and Safari use the property opacity for transparency. The opacity property can take a value from 0.0 - 1.0. A lower value makes the element more transparent. IE8 and earlier use filter:alpha(opacity=x) . The x can take a value from 0 - 100. A lower value makes the element more transparent.
CSS References
CSS Reference CSS Selectors CSS Reference Aural CSS Web Safe Fonts CSS Units CSS Colors CSS Color Values CSS Color Names CSS Color HEX
i m g { o p a c i t y : 0 . 4 ; f i l t e r : a l p h a ( o p a c i t y = 4 0 ) ;/ *F o rI E 8a n de a r l i e r* / } i m g : h o v e r { o p a c i t y : 1 . 0 ; f i l t e r : a l p h a ( o p a c i t y = 1 0 0 ) ;/ *F o rI E 8a n de a r l i e r* / }
The first CSS block is similar to the code in Example 1. In addition, we have added what should happen when a
www.w3schools.com/css/css_image_transparency.asp
1/3
8/4/13
This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box. This is some text that is placed in the transparent box.
< h t m l > < h e a d > < s t y l e > d i v . b a c k g r o u n d { w i d t h : 5 0 0 p x ; h e i g h t : 2 5 0 p x ; b a c k g r o u n d : u r l ( k l e m a t i s . j p g )r e p e a t ; b o r d e r : 2 p xs o l i db l a c k ; } d i v . t r a n s b o x { w i d t h : 4 0 0 p x ; h e i g h t : 1 8 0 p x ; m a r g i n : 3 0 p x5 0 p x ; b a c k g r o u n d c o l o r : # f f f f f f ; b o r d e r : 1 p xs o l i db l a c k ; o p a c i t y : 0 . 6 ; f i l t e r : a l p h a ( o p a c i t y = 6 0 ) ;/ *F o rI E 8a n de a r l i e r* / } d i v . t r a n s b o xp { m a r g i n : 3 0 p x4 0 p x ; f o n t w e i g h t : b o l d ; c o l o r : # 0 0 0 0 0 0 ; } < / s t y l e > < / h e a d > < b o d y > < d i vc l a s s = " b a c k g r o u n d " > < d i vc l a s s = " t r a n s b o x " > < p > T h i si ss o m et e x tt h a ti sp l a c e di nt h et r a n s p a r e n tb o x . T h i si ss o m et e x tt h a ti sp l a c e di nt h et r a n s p a r e n tb o x . T h i si ss o m et e x tt h a ti sp l a c e di nt h et r a n s p a r e n tb o x . T h i si ss o m et e x tt h a ti sp l a c e di nt h et r a n s p a r e n tb o x . T h i si ss o m et e x tt h a ti sp l a c e di nt h et r a n s p a r e n tb o x . < / p > < / d i v > < / d i v > < / b o d y > < / h t m l >
First, we create a div element (class="background") with a fixed height and width, a background image, and a border. Then we create a smaller div (class="transbox") inside the first div element. The "transbox" div have a fixed width, a background color, and a border - and it is transparent. Inside the transparent div, we add some text inside a p element.
Related Searches: CSS Templates AJAX Programming Learn PHP Create HTML Create HTML Pages W eb Design Templates Free HTML Tutorial Learn Basic HTML
Previous
Next Chapter
www.w3schools.com/css/css_image_transparency.asp
2/3
8/4/13
Whether you're new to XML or already an advanced user, the user-friendly views and powerful entry helpers, wizards, and debuggers in XMLSpy are designed to meet your XML and Web development needs from start to finish. New features in Version 2013! XML editor Graphical XML Schema / DTD editors Smart Fix XML validation with automatic error correction XSLT 1.0/2.0 editor, debugger, profiler XQuery editor, debugger, profiler XBRL validator, taxonomy editor, taxonomy wizard New! Chart creation for XML data Support for Office Open XML (OOXML) Graphical WSDL 1.1/2.0 editor & SOAP debugger JSON editing & conversion Java, C#, C++ code generation 32-bit and 64-bit versions HTML5 and CSS3 support Download a free trial today!
Try it now!
Top 10 Tutorials
HTML Tutorial HTML5 Tutorial C SS Tutorial C SS3 Tutorial JavaScript Tutorial jQuery Tutorial SQL Tutorial PHP Tutorial ASP.NET Tutorial XML Tutorial
Top 10 References
HTML/HTML5 Reference C SS 1,2,3 Reference C SS 3 Browser Support JavaScript HTML DOM XML DOM PHP Reference jQuery Reference ASP.NET Reference HTML C olors
Examples
HTML Examples C SS Examples XML Examples JavaScript Examples HTML DOM Examples XML DOM Examples AJAX Examples ASP.NET Examples Razor Examples ASP Examples SVG Examples
Quizzes
HTML Quiz HTML5 Quiz XHTML Quiz C SS Quiz JavaScript Quiz jQuery Quiz XML Quiz ASP Quiz PHP Quiz SQL Quiz
Color Picke
Statistics
RE P O RT E RRO R
HO ME
TO P
P RI N T
FO RU M
A BO U T
W3Schools is optimized for learning, testing, and training. Examples might be simplified to improve reading and basic understanding. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use and privacy policy. C opyright 1999-2013 by Refsnes Data. All Rights Reserved.
www.w3schools.com/css/css_image_transparency.asp
3/3