• 【技术贴】手把手教你做背景半透明的div效果


    今天晚上无聊,去了趟腾讯朋友网,发现了一个很好看的效果,以为是flash做的,结果发现div也是可以做到的,于是就仿造了一个。


    核心代码很简单,就两行。------------------------------------------------------------------------------------ background:rgba(0, 0, 0, 0.4) none repeat scroll 0 0 !important;/*实现FF背景透明,文字不透明*/
     filter:Alpha(opacity=40);background:#000000;/*实现IE背景透明*/------------------------------------------------------------------------------------剩下的就是调整div位置和div字体了,自己看着我的代码慢慢做吧。很简单。


    代码下载地址 :http://115.com/file/dpjx5qn8

    代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>背景半透明效果div源码</title>
    <style type="text/css">
    * {
     margin:0 auto;
    }
    body {
     background-image:url(1280_800_2997.jpg);
    }
    .div {
     position:absolute;
     right:300px;
     background:rgba(0, 0, 0, 0.4) none repeat scroll 0 0 !important;/*实现FF背景透明,文字不透明*/
     filter:Alpha(opacity=40);
     background:#000000;/*实现IE背景透明*/
     color:#FFF;
     padding-top:50px;
     300px;
     height:200px;
     margin-top:120px;
    }
    .div p {
     position:relative;
     text-align:center;
    }
    .div2 {
     300px;
     height:200px;
     background: none repeat scroll 0 0 rgba(0, 0, 0, 0.6);
     filter:Alpha(opacity=40);
     background:#000000;/*实现IE背景透明*/
     border-radius: 2px 2px 2px 2px;
     padding: 1px;
     border:1px dotted red;
     display:none;/* 把此行删了,就能好看到测试div*/
    }
    .hd {
     border-bottom: 1px solid rgba(0, 0, 0, 0.5);
     padding: 0 0 15px 20px;
     position: relative;
    }
    </style>
    </head>

    <body>
    <div class="div">
      <p> <img src="123123.gif" />振 宇 出 品</p>
    </div>
    <div class="div2">
      <div class="hd"> 故意隐藏的测试div。。 </div>
    </div>
    </body>
    </html>

  • 相关阅读:
    linux创建用户和组
    ftp上来显示的时间和系统时间不一致
    在Linux下如何用Shell脚本读写XML?现有一个config.xml(转)
    关于业务主键和逻辑主键
    git push 提示
    浏览器默认样式
    css实现缩进无限嵌套
    使用设置报头x-Frame-Options限制iframe网页嵌套
    chrome控制台小技巧
    git版本库底层命令
  • 原文地址:https://www.cnblogs.com/ae6623/p/4416734.html
Copyright © 2020-2023  润新知