【问题标题】:Over flow hidden and border radius not working when i use css transition scale effects in chrome browser当我在 chrome 浏览器中使用 css 过渡缩放效果时,溢出隐藏和边框半径不起作用
【发布时间】:2014-04-25 05:09:36
【问题描述】:

在我的演示链接中,请旋转图像部分,查看图像超过问题。

当我在 chrome 浏览器中使用 css 过渡缩放效果时,溢出隐藏和边框半径不起作用。

它在 Mozilla Firefox 上运行良好,但 chrome 无法正常运行,我给出了溢出隐藏和边框半径,但悬停图像超出了图像区域。

如何解决这个问题。我尝试了很多时间,但我无法修复并且找不到正确的解决方案。

请点击演示

http://tcxsandbox.com/stack-overflow/

检查第2条评论,我已经放置了小提琴链接。

【问题讨论】:

  • 请在此处包含相关代码,不要在外部站点上,或者创建一个小提琴(jsfiddle.net)
  • 感谢@serakfalcon 的回复。现在创造了一个小提琴。请检查一下。 link

标签: html css


【解决方案1】:

在使用 z-index 并在 child 之前声明 parent(边框半径和溢出隐藏)之后,您必须在相对位置声明父元素,并使用 absolute 声明子元素。示例:

     <div class="parent">
         <img  class="child" src="yourimage.jpg" />
     </div>

<style>
      .parent{
         /*must declare border radius and z-index*/
         position: relative;
         border-radius:100px;
         z-index:5;
       }
     .parent img{    /*Child element*/
            -webkit-transition: all .3s ease-in-out;
            -moz-transition: all .3s ease-in-out ;
            transition: all .3s ease-in-out;
            -webkit-transform: scale(1,1) ;
            -moz-transform: scale(1,1);
            transform: scale(1,1);
            z-index:4;  /*here's where magic happens*/
        }
        .parent img:hover{
            img{
                -webkit-transform: scale(1.1,1.1) ;
                -moz-transform: scale(1.1,1.1);
                -o-transform: scale(1.1,1.1);
                -ms-transform: scale(1.1,1.1);
            }
        }
</style>

这应该可以。 注意:我建议为两个元素(父元素和子元素)声明边框半径,以防止出现交叉浏览问题。

【讨论】:

    【解决方案2】:

    考虑下面的代码:

    .box-main-img {
        -webkit-backface-visibility: hidden;
        -moz-backface-visibility: hidden;
        -webkit-transform: translate3d(0, 0, 0);
        -moz-transform: translate3d(0, 0, 0);
    }
    

    【讨论】:

      【解决方案3】:

      border-radius 添加到您的 box-main-img 类

      .box-main-img {
      float: left;
      width: 100%;
      overflow: hidden;
      height: 143px;
      border-radius: 5px;
      }
      

      FIDDLE

      【讨论】:

      • 感谢@Danield的回复,边界半径正常工作,但是当悬停图像时,图像区域超出的过渡效果不起作用,请你再看看你的小提琴.
      • 对不起,我不明白是什么问题
      • 你能看看我截图中的四个角吗?这出现在 Chrome 版本 32.0.1700.102 上。悬停图像区域时,边框半径和溢出隐藏不起作用。请检查屏幕截图tcxsandbox.com/stack-overflow/screenshot.jpg
      • 我使用的是 chrome 33,但看不到屏幕截图中的黑角。
      • 感谢您抽出宝贵的时间陪伴我,如果您有任何想法,请告诉我
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-06
      • 2017-03-01
      • 2021-12-02
      • 1970-01-01
      • 2018-08-10
      • 2013-06-22
      • 1970-01-01
      相关资源
      最近更新 更多