简体   繁体   English

HTML 5>条件注释和自适应动画

[英]HTML 5 > Conditional Comments and Responsive Animation

I have checked the HTML5 Browser Support and I must say I'm not very happy BUT I still want to use HTML5 Animation in my website. 我已经检查了HTML5 Browser Support ,我必须说我不太满意,但是我仍然想在我的网站中使用HTML5 Animation

The thing is that I want to target all the browser versions that don't support HTML5 Animation and display only an image of the animation if an older version that the ones supported returns true. 问题是,如果不支持HTML5 Animation的浏览器版本返回true,我想定位所有不支持HTML5 Animation的浏览器版本,并且仅显示该动画的图像。

I am aware of IE Conditional Comments , and by the chart below, only IE9 and higher support HTML5 so that will be fixed with a : 我知道IE Conditional Comments ,并且通过下面的图表,仅IE9和更高版本支持HTML5,因此可以使用进行修复:

<!--[if lte IE8]>
  <style type=”text/css”>
    IE lower or equal to IE8 Replace animation coding with an image.
  </style>
<![endif]-->

HTML5 Browser Support chart HTML5浏览器支持图表 在此处输入图片说明

But how do I target let's say Chrome versions lower than 25 or Opera versions lower than 12 ? 但是,如何定位低于25的Chrome版本或低于12的Opera版本呢?

I could do it with a detection pattern so every time your page detects on of those it could use either a different CSS or just another rule. 我可以使用一种检测模式来做到这一点,因此每次您的页面在其中检测到某个页面时,都可以使用其他CSS或其他规则。

If you need help tell it here so i could give your more resources 如果您需要帮助,请在这里告诉我,以便我给您更多资源

If by "HTML5 Animation" you mean you're going to use a canvas, you can readily feature-detect that rather than browser-detecting. 如果通过“ HTML5动画”表示要使用画布,则可以轻松地进行功能检测而不是浏览器检测。 Feature detection, whenever possible, is a much better idea. 只要有可能,特征检测是一个更好的主意。

In this case, you can easily feature-detect canvas support (this particular function is from this answer ): 在这种情况下,您可以轻松进行功能检测画布支持(此特定功能来自此答案 ):

function isCanvasSupported(){
  var elem = document.createElement('canvas');
  return !!(elem.getContext && elem.getContext('2d'));
}

Then in your JavaScript, if isCanvasSupported() is falsey, dynamically insert your fallback content instead. 然后在您的JavaScript中,如果isCanvasSupported()为false,则动态插入您的后备内容。

More about feature-detecting: 有关功能检测的更多信息:

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

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