CSS中灵活使用:before和:after

2020-05-14 07:48:53易采站长站整理

         top:80px;   
         width:50px;   
         height: 50px;   
         background: white;   
         z-index: 2   
     }   
 </style>   
 <div class="first-div"></div>   
 <div class="second-div"></div>   

这里我们将第一个div和第二个div位置放到一起,方便看z-index的效果。以上代码的样式是紫色的正方形里面有个白色的小正方形。因为小正方形的z-index大于大正方形的z-index,所以能显示出,当我们把.first-div的z-index设置为3,这时候就看不到白色的小正方形了,它被紫色的大正方形无情的挡掉了…

zoom 元素缩放比例

zoom适用于所有元素,用于设置或检索对象的缩放比例,对应的脚本特性为zoom,原比例的值是1。

代码:

CSS Code复制内容到剪贴板

<style>   
    .first-div{   
        width: 100px;   
        height: 100px;   
        background: purple;   
        zoom:1.5;   
        float: left  
    }   
    .second-div{   
        width: 100px;   
        height: 100px;   
        background: black;   
        zoom:1;   
        float:left  
    }   
    .third-div{   
        width: 100px;   
        height: 100px;   
        background: red;   
        zoom:.5;   
        float:left  
    }   
</style>   
<div class="first-div"></div>   
<div class="second-div"></div>