温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

css背景色透明但内容不透明的解决方法

发布时间:2021-08-07 23:42:12 来源:亿速云 阅读:124 作者:chen 栏目:web开发

这篇文章主要讲解了“css背景色透明但内容不透明的解决方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“css背景色透明但内容不透明的解决方法”吧!


代码如下:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Css:背景色透明,内容不透明之终极方法!兼容所有浏览器</title>
<style type="text/css">
*{margin:0;padding:0;}
body{background:#3f3f3f;font-family:"宋体", Arial;}
h2, h3, h4, h5, h6, h7{font-weight:normal;font-size:100%;}
img{border:none 0;}
#bos{width:820px;background:#fff;margin:0 auto;}
#bos ul{zoom:1;overflow:hidden;background:#fff;padding:5px 0 5px 5px;}
#bos ul li{width:260px;position:relative;overflow:hidden;float:left;margin:5px;background:#fff;}
.img_wrap{width:258px;border:1px solid #ccc;border-radius:15px;display:block;overflow:hidden;}
#bos ul li h3{width:100%;height:0px;line-height:50px;color:#fff;text-indent:1em;font-size:14px;font-family:微软雅黑;position:absolute;bottom:0px;border-bottom-left-radius:15px;border-bottom-right-radius:15px;filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#44000000',endColorstr='#44000000');background:rgba(0,0,0,.6);}
</style>
</head>
<body>
<div id="bos">
<ul>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14971.jpg">http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg</a>" alt="" /></a>
<h3>网站防诈骗重要提示 购物满59元免运费</h3>
</li>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14972.jpg">http://i1.vanclimg.com/users/18/20120824/r1_120824.jpg</a>" alt="" /></a>
<h3>Android客户端升级新体验 配送延误通知</h3>
</li>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14973.jpg">http://i1.vanclimg.com/users/18/20120824/f8_120824.jpg</a>" alt="" /></a>
<h3>陈年谈品牌的本分 工行e支付可直减60元</h3>
</li>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14971.jpg">http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg</a>" alt="" /></a>
<h3>陈年谈品牌的本分 工行e支付可直减60元</h3>
</li>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14973.jpg">http://i1.vanclimg.com/users/18/20120824/f8_120824.jpg</a>" alt="" /></a>
<h3>陈年谈品牌的本分 工行e支付可直减60元</h3>
</li>
<li>
<a class="img_wrap" href="#"><img _fcksavedurl=""#"><img" src="<a href="https://cache.yisu.com/upload/information/20210311/295/14971.jpg">http://i2.vanclimg.com/users/18/20120824/n1_120824.jpg</a>" alt="" /></a>
<h3>陈年谈品牌的本分 工行e支付可直减60元</h3>
</li>
</ul>
</div>
 <script type="text/javascript">
    var bos = document.getElementById('bos');
    var lis = bos.getElementsByTagName('li');
    var len = lis.length;
    while (len--) {
        lis[len].onmouseover = function () {
            over(this.getElementsByTagName('h3')[0]);
        }
        lis[len].onmouseout = function () {
            out(this.getElementsByTagName('h3')[0]);
        }
    }
    function over(obj) {
        var ypos = 0;
        if (obj.time) {
            clearInterval(obj.time)
        }
        obj.time = setInterval(function () {
            if (ypos < 50) {
                ypos += Math.ceil((50 - ypos) / 3);
            }
            obj.style.height = ypos + "px";
        }, 25);
    }
    function out(obj) {
        var ypos = 50;
        if (obj.time) {
            clearInterval(obj.time)
        }
        obj.time = setInterval(function () {
            if (ypos >= 0) {
                ypos -= Math.ceil((ypos - 0) / 3);
            }
            obj.style.height = ypos + "px";
        }, 25);
    }
</script></body>
</html>

感谢各位的阅读,以上就是“css背景色透明但内容不透明的解决方法”的内容了,经过本文的学习后,相信大家对css背景色透明但内容不透明的解决方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css
AI