2012-11-08 46 views
2

当我应用变换比例“z-索引被改变”时,这是怎么回事? 我错过了什么?玩变形有没有什么“窍门”?变换:比例和定位

.thumb > a .img-cover{ 
    -webkit-transition: all 1.2s ease-out;border-radius:5px; 
    -webkit-transform: scale(1); 
} 
.img-cover{ 
    position:relative; 
    overflow:hidden; 
} 
.img-cover:before{ 
    position:absolute; 
    top:0;left:0;right:0;bottom:0; 
    content:""; 
    box-shadow: inset 0px 0 100px #f0f;} 
.thumb > a:hover img { 
    -webkit-transform: scale(1.1); 
} ​ 

HTML

<div class="container"> 
    <article class="thumb"> 
     <a href="#"> 
      <div class="img-cover"><img src="http://placekitten.com/300/120"/></div> 
      <span>thumb-desc</span> 
     </a> 
    </article> 
</div>​ 

live demo

+0

你缺少的术语“**堆叠内容**”,你可以在菲利普·沃尔顿的文章阅读,[什么没有人告诉你关于Z-指数(HTTP:/ /philipwalton.com/articles/what-no-one-told-you-about-z-index/)。 (为创建新的堆叠上下文,对于具有z-index而不是auto的定位元素,对于**变换**,过滤器,css区域,分页媒体等,不透明度小于1的元素) –

回答

0

自己定义z-index所以它会为你做它。

.img-cover:before{ 
    position:absolute; 
    z-index: 10; 
    top:0;left:0;right:0;bottom:0; 
    content:""; 
    box-shadow: inset 0px 0 100px #f0f;} 
.thumb > a:hover img { 
    z-index: 0; 
    -webkit-transform: scale(1.1); 
} 

Example Code

0

当属性position: absolute被设置,目的是退出该流程。这就是为什么对齐不同,看起来像z-index已经改变。手动设置z-index可以解决这个问题。