简体   繁体   English

需要CSS帮助| 悬停图片| 放大效果

[英]CSS help needed | hover image | zoom in effect

I have this page built in DIVI WordPRess: 我在DIVI WordPRess中建立了此页面:

http://www.wilderfilms.co.uk/wp/work/ http://www.wilderfilms.co.uk/wp/work/

When you hover over an image, I want the zoom effect to work - but the image overlaps outside it's div area. 当您将鼠标悬停在图像上时,我希望缩放效果起作用-但图像在div区域之外重叠。

I used the CSS code from here: https://codepen.io/Remedy/pen/ZYJrpp 我从这里使用了CSS代码: https//codepen.io/Remedy/pen/ZYJrpp

my CSS code which doesn't work is here: 我的CSS代码不起作用在这里:

.et_portfolio_image img {
    max-width: 100%;

   -moz-transition: all 0.3s;
   -webkit-transition: all 0.3s;
   transition: all 0.3s;
}

.et_portfolio_image:hover img {
   -moz-transform: scale(1.1);
   -webkit-transform: scale(1.1);
   transform: scale(1.1);
}

I use firefox browser and I did right click> inspect element on the image, in order to see what class it's been assigned. 我使用firefox浏览器,并右键单击了图像上的检查元素,以便查看已为其分配了什么类。 I've tried different classes, but this seems to be the closest class that looks like what I'm trying to achieve. 我尝试了不同的类,但这似乎是我想要达到的最接近的类。 I basically want the background image to zoom, but not overlap the way it does and keep within the DIV. 我基本上希望背景图像缩放,但不希望重叠并且保持在DIV中。

Thanks! 谢谢!

You have to add some css like below: 您必须添加一些CSS,如下所示:

.et_pb_portfolio_item {
    overflow: hidden;
}

You need to hide any overflow that is caused by the zoom. 您需要隐藏由缩放引起的所有溢出。

Simply add overflow:hidden to the .et_portfolio_image and you are done. 只需将overflow:hidden添加到.et_portfolio_image ,即可完成。

.et_portfolio_image, .et_shop_image {
    display: block;
    position: relative;
    overflow: hidden; }

add this style 添加此样式

.et_portfolio_image, .et_shop_image { overflow: hidden; .et_portfolio_image,.et_shop_image {溢出:隐藏; } }

Thank you to all, the code worked perfect, for benefit of answering this post, I used David's answer: 谢谢所有人,代码工作完美,为了回答这篇文章,我使用了大卫的答案:

.et_portfolio_image, .et_shop_image {
    display: block;
    position: relative;
    overflow: hidden; }

Thank you, the page looks fantastic now! 谢谢,页面现在看起来棒极了!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM