gpt4 book ai didi

css - 标签上缩放的第二次悬停过渡无法正常工作

转载 作者:太空宇宙 更新时间:2023-11-04 07:51:31 24 4
gpt4 key购买 nike

我正在尝试为父项及其子项制作两种不同的 :hover 效果。

HTML

<section class="col large-poster">
<div class="image-area">
<img class="img-cover" src="/path.png" alt="Maven" />
</div>
<div class="poster-cover">
<div>
<h1>
Item
</h1>
</div>
</div>
</section>

不透明度过渡

我正在使用以下代码将不透明度更改为 1:

main#wrap > .page > .group > section.large-poster > .image-area {
position: absolute;
width: 100%;
height: 100vh;
opacity: .265;
transition: 4s ease;
}

main#wrap > .page > .group > section.large-poster:hover > .image-area {
opacity: 1;
}

这很好用,但我也希望能够缓慢地缩放它,我的 CSS 似乎不适用于 :hover 缩放。它建立在与不透明度淡化相同的逻辑上。

规模转变

main#wrap > .page > .group > section.large-poster > .image-area > img {
margin-top: 0;
margin-left: -752px;
width: auto;
/* height: auto */
height: 1000px;
transform:scale(1,1);
transition: 8s all;
}

main#wrap > .page > .group > section.large-poster:hover > image-area > img {
transform:scale(1.2,1.2)
}

jdFiddle link


html {
font-size: 62.5%;
font-family: sans-serif;
box-sizing: border-box;
-webkit-text-size-adjust: 100%;
-moz-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}

body {
padding: 0;
margin: 0 auto;
}

.container:after, .group:before, .group:after, .clearfix:before, .clearfix:after, .row:before, .row:after {
content: '\0020';
display: block;
overflow: hidden;
visibility: hidden;
width: 0;
height: 0;
}

.container:after, .row:after, .clearfix:after, .group:after {
clear: both;
}

.row, .clearfix, .group {
zoom: 1;
}

body, html {
height: 100%;
}

body {
color: #000;
font-weight: 300;
font-size: 16px;
font-size: 1.6rem;
line-height: 1.5;
background: #fff
}

img:not(.img-cover),
svg {
display: block;
max-width: 100%;
height: auto
}

.col {
width: 25%;
float:left;
display:block
}

main {
display: block;
background: black
}

main#wrap > .page > .group > section.large-poster {
min-height: 892px;
height: 100vh;
position: relative;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
}

main#wrap > .page > .group > section.large-poster > .image-area {
position: absolute;
width: 100%;
height: 100vh;
opacity: .265;
transition: 4s ease;
}

main#wrap > .page > .group > section.large-poster:hover > .image-area {
opacity: 1;
}

main#wrap > .page > .group > section.large-poster > .image-area > img {
margin-top: 0;
margin-left: -752px;
width: auto;
/* height: auto */
height: 1000px;
transform:scale(1,1);
transition: 8s all;
}

main#wrap > .page > .group > section.large-poster:hover > image-area > img {
transform:scale(1.2,1.2)
}

main#wrap > .page > .group > section.large-poster > .poster-cover {
position: relative;
z-index: 2;
}

main#wrap > .page > .group > section.large-poster > .poster-cover > div {
margin: 0 40px;
text-align: center
}

main#wrap > .page > .group > section.large-poster > .poster-cover > div > h1 {
text-transform: uppercase;
color: #fff;
font-size: 25px;
font-size: 2.455rem;
line-height: 1.2;
}
    <main id="wrap">
<div class="page">
<div class="group">
<section class="col large-poster">
<div class="image-area">
<img class="img-cover" src="https://wallpapercave.com/wp/k15SYSI.jpg" alt="Maven" />
</div>
<div class="poster-cover">
<div>
<h1>
First
</h1>
</div>
</div>
</section>
<section class="col large-poster">
<div class="image-area">
<img class="img-cover" src="https://wallpapercave.com/wp/k15SYSI.jpg" alt="Maven" />
</div>
<div class="poster-cover">
<div>
<h1>
Second Item
</h1>
</div>
</div>
</section>
<section class="col large-poster">
<div class="image-area">
<img class="img-cover" src="https://wallpapercave.com/wp/k15SYSI.jpg" alt="Maven" />
</div>
<div class="poster-cover">
<div>
<h1>
Third Item
</h1>
</div>
</div>
</section>
<section class="col large-poster">
<div class="image-area">
<img class="img-cover" src="https://wallpapercave.com/wp/k15SYSI.jpg" alt="Maven" />
</div>
<div class="poster-cover">
<div>
<h1>
Last Item
</h1>
</div>
</div>
</section>
</div>
</div>
</main>

最佳答案

你刚刚忘记放一个点

喜欢 .image-area 问题将得到解决:

   main#wrap > .page > .group > section.large-poster:hover > .image-area > img {
transform:scale(1.2,1.2)
}

关于css - <img> 标签上缩放的第二次悬停过渡无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47732508/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com