Chrome 中的 CSS3 过渡

标签 css google-chrome transition

我刚刚注意到一些 CSS3 转换在 Chrome 中停止工作(几周前我检查时还可以工作) - 在 Safari 中似乎很好。 我以前肯定使用过这段代码,但也许这次我忽略了一些东西?

目的只是为了在悬停时实现平滑过渡:

Demo

HTML

<div></div>    

CSS

         div{
    height:100px;
    width:100px;
    background:red;

-webkit-transition-duration: 0.3s;     
-webkit-transition-timing-function: ease-in-out;
-moz-transition-duration: 0.3s;     
-moz-transition-timing-function: ease-in-out;
transition-duration: 0.3s;     
transition-timing-function: ease-in-out;
}

div:hover{
    right:-10px;
    position:relative;
    height:100px;
    width:100px;
    background:red;

-webkit-transition-duration: 0.3s;     
-webkit-transition-timing-function: ease-in-out;
-moz-transition-duration: 0.3s;     
-moz-transition-timing-function: ease-in-out;
transition-duration: 0.3s;     
transition-timing-function: ease-in-out;
}

感谢您的建议

最佳答案

right 不适用于 static 定位元素,您需要在加载时使用 position:relative; 以及您需要定义 right 并将其设置为 0 或您喜欢的任何内容。

Demo

div{
    /* All the properties you have declared will go here plus === */
    right:0; /* Add this */
    position:relative; /* Add this */
}

在加载时使用 position:relative; 将帮助您在鼠标移出以及鼠标悬停时传输元素,因此如果您将 position:relative; 设置为 on :hover 那么你的元素将无法在鼠标移出时传输。

此外,我注意到您没有使用任何标准属性进行转换,因此请确保使用它们。

关于Chrome 中的 CSS3 过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21257754/

相关文章:

google-chrome - Chrome 网络请求不显示 Cookie 选项卡、一些请求 header 、复制为 cURL 已损坏

javascript - Chrome 的窗口调整大小事件问题

html - 给这个 "shape"添加边框

php - 带有 2 行文本的按钮比带有 1 行文本的按钮大,但我需要它们都与 1 行的大小相同

CSS 在 chrome 中不工作,但在 firefox 中工作

d3.js - D3 线插值之间的过渡

ios - 如何修复宽度、高度和变换的 ios 过渡?

ios - SVG 未在 iOS Chrome 和 Safari 上显示?

html - 圆覆盖不拉伸(stretch) 100%

html - CSS 动画在 HTA 中不起作用