菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻

CSS图像的不透明度

原创
05/13 14:22 更新

创建透明图像 - 鼠标悬停效果

<!DOCTYPE html>
<html>
<head>
<style>
    img
    {
    opacity:0.4;
    filter:alpha(opacity=40); /* For IE8 and earlier */
    }
    img:hover
    {
    opacity:1.0;
    filter:alpha(opacity=100); /* For IE8 and earlier */
    }
</style>
</head>
<body>

    <h1>Image Transparency</h1>
    <img src="/statics/images/course/klematis.jpg" width="150" height="113" alt="klematis">
    <img src="/statics/images/course/klematis2.jpg" width="150" height="113" alt="klematis">
    
    <p><b>Note:</b> In IE, a &lt;!DOCTYPE&gt; must be added for the :hover selector to work on other elements than the &lt;a&gt; element.</p>
</body>
</html>

创建一个背景图像与文本的透明框

<!DOCTYPE html>
<html>
<head>
<style>
    div.background
    {
      width: 500px;
      height: 250px;
      background: url(/statics/images/course/klematis.jpg) repeat;
      border: 2px solid black;
    }
    div.transbox
    {
      width: 400px;
      height: 180px;
      margin: 30px 50px;
      background-color: #ffffff;
      border: 1px solid black;
      opacity:0.6;
      filter:alpha(opacity=60); /* For IE8 and earlier */
    }
    div.transbox p
    {
      margin: 30px 40px;
      font-weight: bold;
      color: #000000;
    }
</style>
</head>
<body>
    <div class="background">
        <div class="transbox">
            <p>This is some text that is placed in the transparent box.
            This is some text that is placed in the transparent box.
            This is some text that is placed in the transparent box.
            This is some text that is placed in the transparent box.
            This is some text that is placed in the transparent box.
            </p>
        </div>
    </div>
</body>
</html>
综合评分:9.9 评分 请对本文进行纠错,及学习过程中有困难疑惑可在此进行讨论