Setting opacity in CSS

Last week, I wanted to create a translucent layer to grey out functionality on the site. To do this, create a div that covers the window and set the background color to black.

But how to make it translucent? This webpage on CSS opacity covers how to do this and many other useful things:

.grey_background {
	background: black;
	filter:alpha(opacity=25);
	-moz-opacity:.25;
	opacity:.25;
}

The “filter” rule is for IE (taking advantage of a very old feature that dates back at least 5 years) and the “-moz-opacity” rule is no longer needed for newer versions of Firefox and Mozilla which support the CSS3 spec. Safari also supports the spec.

About tychay

light writing, word loving, ❤ coding
This entry was posted in web development. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.