想法 : 做一個(gè)背景透明 文字不透明的設(shè)計(jì)
方法 一 :
使用opacity后整個(gè)模塊都透明了,展現(xiàn)如下:
那么使用opacity實(shí)現(xiàn)《背景透明摊求,文字不透明》是不可取的。
image
方法 二 :
使用 rgba 來設(shè)置 background-color
background-color:rgba(0,0,0,0.2);
/* IE6和部分IE7內(nèi)核的瀏覽器(如QQ瀏覽器)會(huì)讀懂刘离,但解析為透明 */
demo : 主要使用 絕對(duì)定位 和 RGBA 來實(shí)現(xiàn)
.demo2-bg{
background: url(http://csssecrets.io/images/tiger.jpg) no-repeat;
background-size: cover;
width: 500px;
height: 300px;
position: relative;
}
.demo2{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
width: 500px;
height: 300px;
line-height: 50px;
text-align: center;
background:rgba(255,255,255,0.3);
}
<div class="demo2-bg">
<div class="demo2">背景圖半透明睹簇,文字不透明<br />方法:定位+ background:rgba(255,255,255,0.3)</div>
</div>
image