CSS 悬停放大破坏了设计

发布于 2025-01-09 11:56:48 字数 1118 浏览 0 评论 0原文

我正在与 CSS 语法作斗争,我正在尝试将其应用于下一个代码:

/*========== HOME ==========*/
.home{
    &__img{
        width: 300px;
        border-radius: .5rem;
        justify-self: center;
    }
}

悬停图像效果:要放大图像,让我们用下一个代码说

.zoom {
  padding: 50px;
  transition: transform .2s;
  margin: 0 auto;
}

.zoom:hover {
  -ms-transform: scale(1.5); /* IE 9 */
  -webkit-transform: scale(1.5); /* Safari 3-8 */
  transform: scale(2.5); 
}

我的 HTML div 代码:

 <div class="services__content">
     <img src="assets/img/image.jpg" class="zoom" class="home__img">
     <h3 class="menu__name">some text</h3>
     <span class="menu__detail">some text</span>
     <span class="menu__prices"></span>
 </div>

问题:

当我将鼠标悬停在图像,放大后的图像不会覆盖图像或附近的其他物体,而是在放大时位于图像或其他物体的下方,所有其他物体(例如图像、文本)叠加在放大的图像之上,效果类似于悬停图像的行为作为他们的背景......这对我来说是不正确的。

期望的效果:

当鼠标悬停在图像上时,当它放大时,它应该覆盖最近的对象并且不充当它们的背景,然后当您的光标转到另一图像时,它会恢复到其原始大小,然后下一个图像一个是放大的。

如果有人可以帮助我,我将不胜感激。似乎我所做的一切都不起作用,只是继续落后。同时将继续搜索并尝试进行实验。

谢谢!

I'm battling with CSS syntax and I'm trying to apply it to the next code:

/*========== HOME ==========*/
.home{
    &__img{
        width: 300px;
        border-radius: .5rem;
        justify-self: center;
    }
}

An on hover image effect: To enlarge the image, let's say with the next code

.zoom {
  padding: 50px;
  transition: transform .2s;
  margin: 0 auto;
}

.zoom:hover {
  -ms-transform: scale(1.5); /* IE 9 */
  -webkit-transform: scale(1.5); /* Safari 3-8 */
  transform: scale(2.5); 
}

my HTML div code:

 <div class="services__content">
     <img src="assets/img/image.jpg" class="zoom" class="home__img">
     <h3 class="menu__name">some text</h3>
     <span class="menu__detail">some text</span>
     <span class="menu__prices"></span>
 </div>

Problem:

That when I hover over the image, the enlarged image doesn't cover the images or other objects near and just goes beneath them while being enlarged, all other objects such as images, text, superposition on top of that enlarged image, and the effect are like the hovered image acts as a background for them...which is incorrect for me.

Desired effect:

When hovering over an image, and when it does enlarge, it should cover the nearest objects and not act as a background for them, then when your cursor goes to another image, it gets back to its original size, and the next one is enlarged.

If someone can help me out, I'd appreciate it. It seems everything I do, doesn't work and just keeps going behind. Will keep on searching and trying to experiment with it meanwhile.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文