Gray out image with CSS?

后端 未结 9 2170
轮回少年
轮回少年 2020-12-02 03:55

What\'s the best way (if any) to make an image appear \"grayed out\" with CSS (i.e., without loading a separate, grayed out version of the image)?

My context is that

9条回答
  •  半阙折子戏
    2020-12-02 04:51

    Does it have to be gray? You could just set the opacity of the image lower (to dull it). Alternatively, you could create a

    overlay and set that to be gray (change the alpha to get the effect).

    • html:

    • css:

      #myImage {
          opacity: 0.4;
          filter: alpha(opacity=40); /* msie */
      }
      
      /* or */
      
      #wrapper {
          opacity: 0.4;
          filter: alpha(opacity=40); /* msie */
          background-color: #000;
      }
      

提交回复
热议问题