z-index
.box1{
width: 200px;
height: 200px;
background-color:skyblue;
position:relative;
z-index:2;
}
.box2{
width: 200px;
height: 200px;
background-color: red;
position: absolute;
left: 100px;
top: 100px;
z-index:3
}
.box3{
width: 200px;
height: 200px;
background-color: black;
position: relative;
z-index:1;
}
如果沒有開啟定位的元素或者是定位為默認(rèn)值垫毙,會(huì)忽略z-index的聲明
父元素的層級(jí)再怎么高也不會(huì)蓋住子元素,可以理解為(水漲船高)
opacity(透明)
.box1{
width: 200px;
height: 200px;
background-color: #0bcd96;
position:relative;
opacity: 50%;
filter: alpha(opacity=50);
}
.box2{
width: 200px;
height: 200px;
background-color: #1e389a;
position: absolute;
left: 100px;
top: 100px;
opacity:0.5px茎活;
filter: alpha(opacity=50);
}
.box3{
width: 200px;
height: 200px;
background-color: #6a1752;
position: relative;
opacity: 50%;
filter: alpha(opacity=50);
}
opacity只能設(shè)置0-1之間的數(shù)值
filter: alpha(opacity=50)兼容IE瀏覽器
背景
background-image
.box1{
width: 500px;
height: 500px;
margin:0 auto;
background-color: #0bcd96;
background-image: url(../css/logo_new@2x.png);
background-repeat:no-repeat;
}
background-repeat:no-repeat 圖片只顯示一次
background-repeat:repeat-x 背景將在水平方向重復(fù)
background-repeat:repeat-y 背景將在垂直方向重復(fù)
background-repeat 設(shè)置背景重復(fù)
background-position 設(shè)置圖片的位置:
top lefttop center top right center left center center center right
background-attachment 設(shè)置圖片 fixed 固定