Modernizr is a library for detecting whether the user's browsers have certain features and based on the availability, we developers will trigger certain functions or styles. In this episode, we will take a simple slideshow and use both javascript and css3 to make the transitions based on features available with libraries such as yepnope and html5shiv. Most importantly, we will scratch the surface of what is graceful degradation and progressive enhancement.

If you use modren JS Framework like Angular, when comes to IE8, it will report error.  And I believe, IE9 below will be abandoned, moderen web technology will no longer support IE9 below.

But it will still valuable to know how to handle css / javascript fallback on old bower.

1. installing modernizr

download the entire library from modernizr or cdnjs and put a <script> tag in the <head> of index.html. Open up the browser dev console to see some classes added to the <head> tag:

<html lang="en" style="" class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage websqldatabase indexeddb hashchange history draganddrop websockets rgba hsla multiplebgs backgroundsize borderimage borderradius boxshadow textshadow opacity cssanimations csscolumns cssgradients cssreflections csstransforms csstransforms3d csstransitions fontface generatedcontent video audio localstorage sessionstorage webworkers applicationcache svg inlinesvg smil svgclippaths"><head>

2. feature detection

if a css property is not available:

.box{
box-shadow: 0 0 10px 1px #666;
}
.no-boxshadow .box{
border: 3px solid grey;
}

if a css property is available:

.box{
border: 3px solid grey;
}
.boxshadow .box{
box-shadow: 0 0 10px 1px #666;
}
  1. html5 tags:

    • include the option for html5shiv when generating the modernizr
    • now semantic html5 tags are easily seen in older browser as well
    • if the entire html5shiv library is not needed, then create the html5 element indivudally and put the javascript in the <head>tags
  2. javascript fallback:

<script>
yepnope({
test : Modernizr.cssanimations,
yep : 'slides.css',
nope : 'slides.js'
});
</script>

[CSS3 + HTML5] Modernizr的更多相关文章

  1. CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局

    原文:CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局 效果演示 实现原理 使用3个div(一个是顶部栏,一个是左侧栏,一个是右侧栏): 使用checkbox作为判断是否显示和隐藏 ...

  2. CSS3+HTML5特效9 - 简单的时钟

    原文:CSS3+HTML5特效9 - 简单的时钟 效果演示(加快了100倍)         实现原理 利用CSS3的transform-origin 及 transform 完成以上效果. 代码及说 ...

  3. js+css3+HTML5拖动滑块(type="range")改变值

    最近在做一个H5的改版项目,产品和设计给出的效果中有一个拖动滑块可以改变输入值的效果,类似如下图这样: 拿到这样的设计稿后,我有点懵了,自己写一个js?去网上找一个这样的效果?自己写一个可以,只是实现 ...

  4. 超酷 CSS3/HTML5 3D 飘带菜单实现教程

    今天我们来介绍一款很有创意的CSS3/HTML5菜单,首先菜单是飘带形状的,看起来很优雅,这种菜单在个人博客中用的比较多,不仅干净利落,而且很具有个性化.另外,这款菜单在鼠标滑过菜单项时,将会出现3D ...

  5. 学习笔记 第十二章 CSS3+HTML5网页排版

    第12章   CSS3+HTML5网页排版 [学习重点] 正确使用HTML5结构标签 正确使用HTML5语义元素 能够设计符合标准的网页结构 12.1  使用结构标签 在制作网页时,不仅需要使用< ...

  6. 8款强大的CSS3/HTML5动画及应用源码

    1.CSS3 jQuery UI控制滑杆插件 今天我们要来分享一款基于CSS3和jQuery UI的控制滑杆插件,这款控制滑杆是在HTML5滑杆元素的基础上进行自定义CSS3渲染,所以外观更加漂亮.另 ...

  7. CSS3/HTML5实现漂亮的分步骤注册登录表单

    分步骤的登录注册表单现在也比较多,主要是能提高用户体验,用户可以有选择性的填写相应的表单信息,不至于让用户看到一堆表单望而却步.今天和大家分享的就是一款基于HTML5和CSS3的分步骤注册登录表单,外 ...

  8. CSS3&HTML5各浏览器支持情况一览表

    http://fmbip.com/ CSS3性质(CSS3 Properties) 平台 MAC WIN 浏览器 CHROME FIREFOX OPERA SAFARI CHROME FIREFOX ...

  9. CSS3+HTML5实现块阴影与文字阴影

    CSS 3 + HTML 5 是未来的 Web,它们都还没有正式到来,虽然不少浏览器已经开始对它们提供部分支持.本教程分5节介绍了 5 个 CSS3 技巧,可以帮你实现未来的 Web,不过,这些技术不 ...

随机推荐

  1. merge into Oracle里的 saveOrUapdate

    1.初始数据: SQL> select * from a; ID NAME ---------------------- ---------------------- 1 1 2 1 3 1 4 ...

  2. Swift - 25 - 控制转移和二维数组

    //: Playground - noun: a place where people can play import UIKit // fallthrough // fallthrough会在当前c ...

  3. tomcat启动报错:Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable

    linux 下 启动tomcat 报: Neither the JAVA_HOME nor the JRE_HOME environment variable is definedAt least o ...

  4. springmvc数组参数传递

    在开发中遇到将form中的name值一样的多个input元素传递到后台,我用的是springmvc. 刚开始的时候老是报400的请求错误.后来查了下资料,其实解决方案挺简单的. 我的后台control ...

  5. Spring4.0学习笔记(6) —— 通过工厂方法配置Bean

    1.静态工厂方法: bean package com.spring.factory; public class Car { public Car(String brand) { this.brand ...

  6. javascript 判断是否是PC还是手机端

    function IsPC() { var userAgentInfo = navigator.userAgent; var Agents = new Array("Android" ...

  7. GFStableList Adapter

    STL中,list的优点是插入.删除性能极佳(时间复杂度只需O(1)即可),而且非常重要的在删除节点后,其迭代器不失效,但list查找却不擅长.map由于其实现的数据结构为rb-tree,因此,其插入 ...

  8. Linux_hadoop_install

    1. Build Linux env my env is VM RedHat Linux 6.5 64bit    set fixed IP                  vim /etc/sys ...

  9. Solr4.8.0源码分析(5)之查询流程分析总述

    Solr4.8.0源码分析(5)之查询流程分析总述 前面已经写到,solr查询是通过http发送命令,solr servlet接受并进行处理.所以solr的查询流程从SolrDispatchsFilt ...

  10. 关于如何在C语言中嵌入汇编命令

    转载自:http://www.keil.com/support/docs/2308.htm C51: GETTING INLINE ASSEMBLY TO WORK Information in th ...