元素的层级和背景

2018-11-24  本文已影响0人  姓高名旭升
z-index
   .box1{
        width: 200px;
        height: 200px;
        background-color: #0bcd96;
        position:relative;
        z-index:3;
    }
    .box2{
        width: 200px;
        height: 200px;
        background-color: #1e389a;
        position: absolute;
        left: 100px;
        top: 100px;
    }
    .box3{
        width: 200px;
        height: 200px;
        background-color: #6a1752;
        position: relative;
        z-index:2;
    }


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);
    }


背景(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;
    }

上一篇下一篇

猜你喜欢

热点阅读