Opacity Cross Browser

Sometimes we need to use opacity in our css.

Here is the example.

.opacity{
    opacity: 0.5;
}

We need to write the same code for all browsers.

Here the code of opacity for cross browsers.

.opacity{
  /* IE 8 */
  -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

  /* IE 5-7 */
  filter: alpha(opacity=50);

  /* Netscape */
  -moz-opacity: 0.5;

  /* Safari 1.x */
  -khtml-opacity: 0.5;

  /* Good browsers */
  opacity: 0.5;
}

We need to add this code in our CSS file for opacity.



Related articles