【发布时间】:2017-07-06 01:17:14
【问题描述】:
有没有办法为父元素设置变换,而不是为子元素?我尝试将变换的反向值设置为子元素。它可以工作,但嵌套动画不会线性运行,即使有transition: all 1s linear;。这里是example。
.container, .title {
transition: all 1s linear;
}
.image {
background-image: url(https://www.w3schools.com/css/trolltunga.jpg);
height: 300px;
width: 800px;
}
.container {
transform: scale(0.1); // 0.1× size of parent
}
.title {
text-align: center;
padding-top: 1rem;
transform: scale(10); // 10× size of child
}
.container:hover {
transform: scale(0.5); // 0.5× size of parent on hover
}
.container:hover .title {
transform: scale(2); // 2× size of child on hover
}
<div class="container">
<div class="image">
</div>
<h1 class="title">Title</h1>
</div>
【问题讨论】:
-
我不这么认为。我这就是你想要的效果? jsfiddle.net/ubw34Lj8/1
-
不,没有。唯一的选择是将孩子们变回另一种方式。
标签: html css transform css-transforms