用户登录
用户注册

分享至

背景透明,文字不通明的做法

  • 作者: 我是坏人8190
  • 来源: 51数据库
  • 2022-08-15
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.51sjk.com/Upload/Articles/1/0/321/321859_20220815180130457.jpg">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>背景透明文字不通明</title>
<style type="text/css">
	.item{width:400px;height:300px;margin:0 auto;position:relative;}
	.hi,h3{position:absolute;left:0;bottom:0;width:100%;height:30px;}
	h3{line-height:30px;color:#fff;margin:0;z-index:1;}/*给文字设置了z-index值这样文字就不会透明了*/
	.hi{background:red;opacity:0.4;}/*透明背景*/
</style>
</head>

<body>
	<h1>背景透明文字不透明的做法</h1>
    <div class="item">   	
    	<p>
        	<img src="http://www.51sjk.com/Upload/Articles/1/0/321/321859_20220815180132629.jpg" />
        </p>
        <h3>你看我是不是没有透明啊</h3>
        <div class="hi"></div>
    </div>
</body>
</html>
软件
前端设计
程序设计
Java相关