CSS opacity属性的覆盖性实例页面

回到相关文章 »

代码:

CSS代码:
.opacity1, .opacity2, .opacity_img { display: inline-block; }
.opacity1 { filter: Alpha(opacity=0); }
.opacity2 { filter: Alpha(opacity=50); }
.opacity_img { filter: Alpha(opacity=100); }
:root .opacity1 { opacity: 0; filter: none; }
:root .opacity2 { opacity: .5; filter: none; }
:root .opacity_img { opacity: 1; filter: none; }
                
HTML代码:
<p>
    <a href="#" class="opacity1">
        <img class="opacity_img" src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" />
    </a>
</p>
<p>
    <a href="#" class="opacity2">
        <img class="opacity_img" src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" />
    </a>
</p>
<p>
    <a href="#" class="opacity2">
        <img class="opacity2" src="//image.zhangxinxu.com/image/study/s/s256/mm1.jpg" />
    </a>
</p>
                

效果: