Google Chrome 中的 CSS 转换延迟

Posted

技术标签:

【中文标题】Google Chrome 中的 CSS 转换延迟【英文标题】:CSS transition delay in Google Chrome 【发布时间】:2017-09-05 16:15:09 【问题描述】:

当您将鼠标悬停在一个圆圈上时,文本颜色应与旋转和背景颜色同时发生变化。

Firefox、IE、Edge 都按预期制作动画,但 Chrome 会延迟文本颜色的转换,就好像它在动画之前等待旋转完成,甚至在旋转和文本颜色更改之间留有间隙。

http://codepen.io/rachelreveley/pen/YNZawG

body 
  text-align: center;
  background-color: #122d40;

a 
  display: inline-block;
  width: 20rem;
  height: 20rem;
  margin: 1rem;
  transition: all 1s ease;
  position: relative;
  border-radius: 100%;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  background-color: #7fb400;
  transform: rotate(0deg);

a > span,
a span span 
  display: block;
  transition: inherit;

a span span:first-child 
  position: absolute;
  width: 100%;
  height: 100%;
  top: 40%;
  text-transform: uppercase;
  font-size: 40px;

a span span:last-child 
  opacity: 0;
  padding: 2rem 3rem;

a:hover 
  background-color: #fff;
  color: #122d40;
  transform: rotate(360deg);

a:hover span span:first-child 
  opacity: 0;

a:hover span span:last-child 
  opacity: 1;
 
<a href=""><span><span>Space</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span> </span></a>
<a href=""><span><span>Speed</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span></span></a>
<a href=""><span><span>Support</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span></span></a>

【问题讨论】:

【参考方案1】:

问题出在这里:

a > span,
a span span 
  transition: inherit;

这个过渡真的需要吗? 尝试删除该属性。

body 
  text-align: center;
  background-color: #122d40;

a 
  display: inline-block;
  width: 20rem;
  height: 20rem;
  margin: 1rem;
  transition: all 1s ease;
  position: relative;
  border-radius: 100%;
  text-decoration: none;
  color: #fff;
  overflow: hidden;
  background-color: #7fb400;
  transform: rotate(0deg);

a > span,
a span span 
  display: block;

a span span:first-child 
  position: absolute;
  width: 100%;
  height: 100%;
  top: 40%;
  text-transform: uppercase;
  font-size: 40px;

a span span:last-child 
  opacity: 0;
  padding: 2rem 3rem;

a:hover 
  background-color: #fff;
  color: #122d40;
  transform: rotate(360deg);

a:hover span span:first-child 
  opacity: 0;

a:hover span span:last-child 
  opacity: 1;
<a href=""><span><span>Space</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span> </span></a>
<a href=""><span><span>Speed</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span></span></a>
<a href=""><span><span>Support</span><span><h1>Lorem ipsum</h1> dolor sit amet, consectetur adipiscing elit. Ita nemo beato beatior. Si longus, levis; Utinam quidem dicerent alium alio beatiorem! Iam alium alio ruinas videres. Tamen a proposito, inquam, aberramus. </span></span></a>

【讨论】:

以上是关于Google Chrome 中的 CSS 转换延迟的主要内容,如果未能解决你的问题,请参考以下文章

Google Chrome 中的 CSS 图像悬停问题

如何修复 Chrome 中的页面滚动延迟

css:悬停在chrome中无法延迟动态添加的类

获取 Google Chrome 开发工具中选定元素的所有 CSS 规则

google chrome 调试css怎么禁止缓存

google chrome 调试css怎么禁止缓存