- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我的环境(哪里有延迟):
Chrome 版本 50.0.2661.102(64 位)上的 Mac OSX El Capitan 10.11.2
编码:
http://codepen.io/vieron/pen/hnEev
动画:
情况:
我在谷歌上搜索了很多,但没有找到适合我的东西。我知道以前有人问过这个问题。
当我使用 Safari 和 Firefox 打开网站时,CSS3 动画在我的 Mac 上很流畅,但使用 Chrome 却不行!
奇怪的是,原来的 CodePen 在 Chrome 上很流畅。
问题:
我的代码中的某些内容导致动画仅在 Chrome 上不稳定。它是什么以及如何修复它?
我看到了什么:
我需要相对定位以适应不同的屏幕尺寸。
http://blog.teamtreehouse.com/create-smoother-animations-transitions-browser
https://www.binarymoon.co.uk/2014/02/fixing-css-transitions-in-google-chrome/
http://blog.teamtreehouse.com/create-smoother-animations-transitions-browser
代码:
HTML
<div class="marquee">
<ul>
<li>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
</li>
<li>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
</li>
<li>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
<a href="https://developer.apple.com/swift/"><img class="marquee-itm" src="Vendors/Images/Apple_Swift_Logo.png" /></a>
<a href="https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/Introduction/Introduction.html"><img class="marquee-itm" src="Vendors/Images/Objective-c-logo.png" /></a>
</li>
</ul>
</div>
CSS
* {
margin: 0;
padding: 0;
}
@-webkit-keyframes loop {
0% {
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-moz-transform: translateX(-66.6%);
-ms-transform: translateX(-66.6%);
-webkit-transform: translateX(-66.6%);
transform: translateX(-66.6%);
}
}
@-moz-keyframes loop {
0% {
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-moz-transform: translateX(-66.6%);
-ms-transform: translateX(-66.6%);
-webkit-transform: translateX(-66.6%);
transform: translateX(-66.6%);
}
}
@-ms-keyframes loop {
0% {
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-moz-transform: translateX(-66.6%);
-ms-transform: translateX(-66.6%);
-webkit-transform: translateX(-66.6%);
transform: translateX(-66.6%);
}
}
@keyframes loop {
0% {
-moz-transform: translateX(0);
-ms-transform: translateX(0);
-webkit-transform: translateX(0);
transform: translateX(0);
}
100% {
-moz-transform: translateX(-66.6%);
-ms-transform: translateX(-66.6%);
-webkit-transform: translateX(-66.6%);
transform: translateX(-66.6%);
}
}
.cssanimations .marquee {
position: relative;
width: 90%;
margin: auto;
overflow: hidden;
}
.cssanimations .marquee > ul {
list-style: none;
position: relative;
z-index: 1;
top: 0;
left: 0;
width: 300% !important;
height: 80px;
-webkit-animation-play-state: running;
-moz-animation-play-state: running;
-o-animation-play-state: running;
animation-play-state: running;
-moz-transform: translate3d(0, 0, 0);
-ms-transform: translate3d(0, 0, 0);
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
-webkit-animation: loop 20s linear infinite;
-moz-animation: loop 20s linear infinite;
-o-animation: loop 20s linear infinite;
animation: loop 20s linear infinite;
}
.cssanimations .marquee > ul > li {
white-space: normal;
position: relative;
text-align: justify;
text-justify: distribute-all-lines;
line-height: 0;
letter-spacing: -0.31em;
float: left;
width: 33.333333%;
overflow: hidden;
height: 80px;
}
.cssanimations .marquee > ul > li:before {
content: '';
position: relative;
height: 100%;
width: 0;
}
.cssanimations .marquee > ul > li:before,
.cssanimations .marquee > ul > li > * {
vertical-align: middle;
display: inline-block;
}
.cssanimations .marquee > ul > li:after {
content: '.';
display: inline-block;
height: 0 !important;
width: 100%;
overflow: hidden !important;
visibility: hidden;
font-size: 0;
word-spacing: 100%;
}
.cssanimations .marquee > ul > li > * {
display: inline-block;
vertical-align: middle;
text-align: left;
line-height: 1;
letter-spacing: 0;
}
.cssanimations .marquee > ul > li img {
margin: 0 1.6%;
}
.marquee ul li a{
display: inline-block;
height: 80%;
}
.marquee ul li a img {
max-height: 100%;
}
HTML 中的 JS 链接
<script src="Vendors/js/modernizr.js" type="text/javascript"></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
重要注意事项:
我唯一添加到 CodePen 的东西:
.marquee ul li a{
display: inline-block;
height: 80%;
}
.marquee ul li a img {
max-height: 100%;
}
删除它并不能解决问题。
编辑 1:
Google Chrome Profiler(选项 1):
Google Chrome Profiler(选项 2(快照)):
编辑 2:
CSS3 transition not smooth in Chrome
我似乎刚刚在我的动画中发现了一个奇怪的行为。每当我离开视线并通过滚动回到它时,它就会“变大”(变大)。
此行为似乎是上述问题的答案中所描述的。但是像建议的那样指定固定宽度并不能解决延迟问题。
编辑 3:
Google 时间轴(删除 gravity.js 后):
编辑 4:
这很奇怪。在注释和取消注释某些行之后(基本上回到有延迟时的代码),动画性能变得更好。不如在 Safari 或 Firefox 中流畅,但仍然流畅。
编辑 5:
我找到了“罪魁祸首”。
我在我网站的标题中使用了另一个代码笔:
https://codepen.io/saransh/pen/BKJun
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
#stars
#stars2
#stars3
#title
%span
PURE CSS
%br
%span
PARALLAX PIXEL STARS
删除它会使其他动画平滑。
尽管如此:
这并不能解释为什么在 Firefox 和 Safari 中一切顺利,但在 Chrome 中却不顺利。
Chrome 是否功能较弱?
我向 Chrome 提交了一份报告,希望他们会在这里答复,但不能保证。
如果有人可以从 Google/Chrome 得到答案,我会奖励他/她。
更新 6:
在 Opera 浏览器上试过。完全一样的滞后!现在我们知道这是 BLINK 渲染引擎的问题!
最佳答案
Chrome 在渲染时支持硬件加速,提高了 css3 动画的性能。你可以trigger hardware acceleration通过应用 translateZ(0)
、rotateZ(360deg)
或类似的东西来欺骗 Chrome。
一旦您通过应用上述技巧来使用硬件加速(或者如果您已经在使用它,但引用的代码示例不完整和/或第三方库正在为您处理),您可以根据需要使用前缀来进一步提高性能:
backface-visibility: hidden;
perspective: 1000;
这也有助于解决当 GPU 被集成和/或被节流(想想省电模式)时性能下降的一些问题。这可以解释 macbook 上的视差性能问题! ¯\_(ツ)_/¯
关于html - 为什么我的 CSS3 动画在 Google Chrome 中不流畅(但在其他浏览器中非常流畅)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37629745/
更新:随意给我反对票,因为问题是我将文件命名为 _stylesheet.html.erb 而不是 _stylesheets.html.erb。我以为我检查了拼写,但显然我没有。我很抱歉浪费了大家的时间
我有一个 Inno Script istaller 在其中运行子 setup.exe 。当向主安装程序提供静默安装参数时,我必须向 setup.exe 提供静默安装参数。 Inno脚本运行命令: [R
我正在尝试在大型数据库中搜索长的、近似的子字符串。例如,一个查询可能是一个 1000 个字符的子字符串,它可能与匹配项相差数百个编辑的 Levenshtein 距离。我听说索引 q-gram 可以做到
我正在尝试在我的应用程序中实现一个非常简单的绘图 View 。这只是我的应用程序的一小部分,但它正在变成一个真正的麻烦。这是我到目前为止所拥有的,但它现在显示的只是莫尔斯电码,如点和线。 - (v
我有一个运行非常慢的 sql 查询,我很困惑为什么。查询是: SELECT DISTINCT(c.ID),c.* FROM `content` c LEFT JOIN `content_meta`
我搜索过这个,但我发现的所有结果对我来说都毫无意义,而且似乎太复杂了。我希望使用 json 或 simplejson 模块来获取对象中字符串的值。 string = '{"name": "Alex"}
我想编写一个流量生成器来复制正在运行的计算机对内存进行的原始读写需求。 但是正在运行的计算机在其内存引用中也显示出(非常强的)局部性,并且在 64 位地址空间中,只会引用非常小范围的地址(事实上,我已
我正在尝试做一个 Project Euler问题,但它涉及添加一个非常大的数字的数字。 (100!) 用Java的int和long太小了。 谢谢你的建议 最佳答案 类 BigInteger看起来它可能
我想在游戏中实现一个物理引擎,以便计算物体在受力时的轨迹。该引擎将根据对象的先前状态计算对象的每个状态。当然,这意味着要在两个时间单位之间进行大量计算才能足够精确。 为了正确地做到这一点,我首先想知道
Edit3:通过将数组的初始化限制为仅奇数进行优化。谢谢@Ronnie! Edit2:谢谢大家,看来我也无能为力了。 编辑:我知道 Python 和 Haskell 是用其他语言实现的,并且或多或少地
背景 我有一个我编写的简单媒体客户端/服务器,我想生成一个非显而易见的时间值,我随每个命令从客户端发送到服务器。时间戳将包含相当多的数据(纳秒分辨率,即使由于现代操作系统中定时器采样的限制,它并不真正
一位招聘软件工程师的 friend 希望我为他开发一个应用。 他希望能够根据技能搜索候选人的简历。 正如您想象的那样,可能有数百、可能数千种技能。 在表格中表示候选人的最佳方式是什么?我在想 skil
我的意思是“慢”,回调类型等待远程服务器超时以有效触发(调用 vimeo 提要,解析它,然后在场景中显示 uiviews) 我大多不明白它是如何工作的。我希望在返回响应后立即从回调中填充我的 View
您好,我正在研究使用快速可靠的生产者消费者队列进行线程切换。我正在使用 VC++ 在 Windows 上工作。 我的设计基于 Anthony Williams队列,基本上就是一个带有 boost::c
我只是想知道您使用 resharper 的经验。我们有一个非常重的 dbml 文件,因为我们的数据库有很多表,每次我需要打开该文件时,我都会收到来自 resharper 的大量异常。以前有人遇到过这个
我目前正在使用 jQuery 中的隐藏/显示功能来帮助从选择框中将表格过滤成组。 实际代码运行良好,但速度非常慢,有时需要一两分钟才能执行。 我切换了代码,所以它使用 css({'display':'
我按顺序调用了以下两个方法(按顺序使用适当的类级别字段) public const string ProcessName = "This is" public const string WindowT
我很难理解描述反射包的文档/示例。我是一名命令式编程老手,但也是一名 Haskell 新手。你能引导我完成一个非常简单的介绍吗? 包裹:https://hackage.haskell.org/pack
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我正在尝试编写一段代码来操作一个很长的文档(超过一百万行)。在这个文本文件中,有固定间隔(每 1003 行)和之间的某些时间戳有我需要的数据,它有 1000 行长,还有一个标题和两个空行,但我不需要。
我是一名优秀的程序员,十分优秀!