How to change the opacity of image on hover using css

后端 未结 1 578
青春惊慌失措
青春惊慌失措 2020-12-10 03:29

I\'m trying to figure out how to set all images to be 50% opacity initially, and then change to 100% opacity on hover.

I tried sett

相关标签:
1条回答
  • 2020-12-10 03:54

    Your code is good- verified in this Fiddle with a friendly fish: http://jsfiddle.net/Qrufy/

        img {
            opacity: 0.5;
            filter: alpha(opacity=40);
        }
        
        img:hover {
            opacity: 1.0;
            filter: alpha(opacity=100);
        }
        <img src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/15/Colossoma_macropomum_01.jpg/800px-Colossoma_macropomum_01.jpg" />

    The opacity property works in all modern browsers, and the filter:alpha covers <= IE8.

    0 讨论(0)
提交回复
热议问题