匀速层级和背景

2018-11-26  本文已影响0人  bda1a329d33d

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

opacity(透明)

.box1{
    width: 200px;
    height: 200px;
    background-color: gold;
    position:relative;
    opacity: 50%;
    filter: alpha(opacity=50);
}
.box2{
    width: 200px;
    height: 200px;
    background-color: green
    left: 100px;
    top: 100px;
    opacity:0.5px;
    filter: alpha(opacity=50);
}
.box3{
    width: 200px;
    height: 200px;
    background-color:pink;
    position: relative;
    opacity: 50%;
}

opacity只能设置0-1之间的数值
filter: alpha(opacity=50)兼容IE浏览器


背景

background-image

.box1{
    width: 500px;
    height: 500px;
    margin:0 auto;
    background-color: #0bcd96;
    background-image: url();
    background-repeat:no-repeat;
}

background-repeat:no-repeat 图片只显示一次
background-repeat:repeat-x 背景将在水平方向重复
background-repeat:repeat-y 背景将在垂直方向重复

上一篇下一篇

猜你喜欢

热点阅读