2016-07-23 93 views
0

我想在我的子div中禁用變換。這裏是fiddle。是否可以禁用類.image-text的比例?在CSS中禁用變換兒童

.photo:hover{ 
    transform: scale(1.4); 
    -moz-transform: scale(1.4); 
    -webkit-transform: scale(1.4); 
    -o-transform: scale(1.4); 
    -ms-transform: scale(1.4); 
    } 

    .photo:hover >*{ 
    transform: none; 
    } 

回答

0

你可以看到這些例子。

.element{ 
 
    width: 400px; 
 
    height: 550px; 
 
    } 
 
    
 
    img { 
 
    max-width: 100%; 
 
    height: auto; 
 
    vertical-align: middle; 
 
    border: 0; 
 
    } 
 
    
 
    .main-photo-area { 
 
    position:relative; 
 
    display: block; 
 
    overflow: hidden; 
 
} 
 
    .main-photo-area img.photo{ 
 
    transition: all 0.3s ease; 
 
    
 
    width: 100%; 
 
} 
 

 
    .main-photo-area:hover img.photo{ 
 
    transform: scale(1.4); 
 
    } 
 

 

 
    .image-text { 
 
    background: rgba(34, 90, 159, 0.6); 
 
    bottom: 0; 
 
    color: white; 
 
    font-size: 1em; 
 
    left: 0; 
 
    opacity: 0; 
 
    overflow: hidden; 
 
    padding: 3em 3em 4.25em 3em; 
 
    position: absolute; 
 
    text-align: center; 
 
    top: 0; 
 
    right: 0; 
 
    -webkit-transition: 0.6s; 
 
    transition: 0.6s; 
 
    } 
 

 
    .image-text:hover { 
 
    opacity: 1; 
 
    }
<div class="element"> 
 
    <div class="main-photo-area"> 
 
    <img class="photo" src="http://heavytable.com/wp-content/uploads/2012/11/wine-glasses-650-325.jpg"/> 
 
\t <a class="over" href="/szablon/?id=single"> 
 
     <div class="image-text"> 
 
     <h2>Titel</h2> 
 
     <p>Desc</p> 
 
     <span class="icon">Look</span> 
 
     </div> 
 
\t </a> 
 
    </div> 
 
</div>