我有这样的css&html代码:

.item-video-kami {
  width: 480px;
  overflow: hidden;
  position: relative;
}

.item-video-kami>.play-icon.full-height>svg {
  width: 106px;
  color: #ffffff50;
}

.item-video-kami img {
  transition: all .5s ease;
}

.item-video-kami>.play-icon {
  height: 100%;
  position: absolute;
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  background-color: #1e1e1e94;
  opacity: 0;
  /* Initial opacity set to 0 */
  transition: opacity 0.2s ease-in 0.1s;
}

.item-video-kami:hover img {
  transform: scale(1.1);
}

.item-video-kami:hover .play-icon {
  opacity: 0.8;
  /* Adjusted opacity value to 0.8 for 80% */
}
<a href="#" class="item-video-kami">
  <div class="play-icon full-height">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
                            <path fill-rule="evenodd"
                                d="M4.5 5.653c0-1.427 1.529-2.33 2.779-1.643l11.54 6.347c1.295.712 1.295 2.573 0 3.286L7.28 19.99c-1.25.687-2.779-.217-2.779-1.643V5.653Z"
                                clip-rule="evenodd" />
                        </svg>
  </div>
  <img src="https://picsum.photos/200/300" alt="">
</a>

<a href="#" class="item-video-kami">
  <div class="play-icon full-height">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
                            <path fill-rule="evenodd"
                                d="M4.5 5.653c0-1.427 1.529-2.33 2.779-1.643l11.54 6.347c1.295.712 1.295 2.573 0 3.286L7.28 19.99c-1.25.687-2.779-.217-2.779-1.643V5.653Z"
                                clip-rule="evenodd" />
                        </svg>

  </div>
  <img src="https://picsum.photos/200/300" alt="">
</a>

预期的结果是,当光标悬停在.Item-Video-kami上方时,图像将zoom (放大),同时,div.play-图标将不透明度更改为0.8

但在上面的片断中,动画只用于放大图像,而第二个动画不是触发器(如果不清楚,请判断片断)

推荐答案

这是预期的yields 吗?

.item-video-kami {
  overflow: hidden;
  position: relative;
  position: relative;
  height: 100%;
  display: inline-block;
}

.item-video-kami>.play-icon.full-height>svg {
  width: 106px;
  color: #ffffff50;
}

.item-video-kami img {
  transition: all .5s ease;
}

.item-video-kami>.play-icon {
    height: 100%;
    position: absolute;
    display: flex;
    width: 100%;
    justify-content: center;
    align-items: center;
    background-color: #1e1e1e94;
    opacity: 0;
    top: 0;
    transition: opacity 0.2s ease-in 0.1s;
    bottom: 0;
    left: 0;
    right: 0;
}

.item-video-kami:hover img {
  transform: scale(1.1);
}

.item-video-kami:hover .play-icon {
  z-index: 2;
  opacity: 0.8;
  /* Adjusted opacity value to 0.8 for 80% */
}
<a href="#" class="item-video-kami">
  <div class="play-icon full-height">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
                            <path fill-rule="evenodd"
                                d="M4.5 5.653c0-1.427 1.529-2.33 2.779-1.643l11.54 6.347c1.295.712 1.295 2.573 0 3.286L7.28 19.99c-1.25.687-2.779-.217-2.779-1.643V5.653Z"
                                clip-rule="evenodd" />
                        </svg>
  </div>
  <img src="https://picsum.photos/200/300" alt="">
</a>

<a href="#" class="item-video-kami">
  <div class="play-icon full-height">
    <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" class="w-6 h-6">
                            <path fill-rule="evenodd"
                                d="M4.5 5.653c0-1.427 1.529-2.33 2.779-1.643l11.54 6.347c1.295.712 1.295 2.573 0 3.286L7.28 19.99c-1.25.687-2.779-.217-2.779-1.643V5.653Z"
                                clip-rule="evenodd" />
                        </svg>

  </div>
  <img src="https://picsum.photos/200/300" alt="">
</a>

Html相关问答推荐

HTML CSS如何使用图像作为中心点将元素置于中心

使用固定的HTML代码创建两个可向右滚动的行

如何将grid—template—column应用于元素中的子元素

如何获得一个背景图像,不是模糊的内部容器,但模糊的外部'

如何在angular 17.2中使用routerLink解决此错误

窗口对象中是否有对<;html&>根元素的引用?

如何将FlexBox项目zoom 到其包含图像的大小

为什么这个高度为100%的页面会出现滚动条?

将ANGLE模板高效地迁移到ANGLE 17中引入的新语法

粘滞的导航栏延伸到超过页边距的右侧

窗口视图之外的下拉菜单位置

现代网络浏览器可以并行下载哪些类型的网络资源?还有,什么东西不能并行下载?

我正在try 向列表中的图像添加悬停,以放大图像并将div的不透明度设置为1而不是0

动画的停止和启动并不顺利

如何在ASP.NET Core中添加换行符

如果使用复选框属性更改,如何防止事件更改?

在DIV上应用梯度模糊未如预期工作

如何制作一个布局,其中左侧固定为图像,右侧为按钮,中心或中间位置为文本?

如何在 bootstrap 程序导航栏中居中搜索图标

是否可以使用纯 css 创建具有斜角效果的锯齿形边缘?