码迷,mamicode.com
首页 > Web开发 > 详细

CSS创建透明图像

时间:2017-06-26 11:31:58      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:safari   utf-8   margin   ref   ie8   set   jpg   chrome   透明   

CSS 图像透明/不透明

CSS Opacity属性是W3C的CSS3建议的一部分。
创建透明图像 - 悬停效果创建一个透明图像
CSS3中属性的透明度是 opacity。
img
{
opacity:0.4;
filter:alpha(opacity=40); /* IE8 及其更早版本 */
}
IE9,Firefox,Chrome,Opera,和Safari浏览器使用透明度属性可以将图像变的不透明。 Opacity属性值从0.0 - 1.0。值越小,使得元素更加透明。
IE8和早期版本使用滤镜:alpha(opacity= x)。 x可以采取的值是从0 - 100。较低的值,使得元素更加透明。


图像的透明度 - 悬停效果
CSS样式:
img
{
opacity:0.4;
filter:alpha(opacity=40); /* IE8 及其更早版本 */
}
img:hover
{
opacity:1.0;
filter:alpha(opacity=100); /* IE8 及其更早版本 */
}

 

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>图像透明</title>
    <style>
        div{
            width: 182px;
            height: 141px;
            margin: 300px auto;

        }
        div img{
            opacity: 0.7;
            filter: alpha(opacity=70);
        }

        div img:hover{
            opacity: 1;
            filter: alpha(opacity=100);
        }
    </style>
</head>
<body>
    <div>
        <img src="beauty.jpg" alt="美女"/>
    </div>
</body>
</html>

  

CSS创建透明图像

标签:safari   utf-8   margin   ref   ie8   set   jpg   chrome   透明   

原文地址:http://www.cnblogs.com/mylove-huan/p/7079550.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!