[CSS3 + HTML5] Modernizr
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;
}
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
javascript fallback:
- for a javascript fallback, use yepnope.js - ensure it is part of the generated modernizr as well. Put the scripts in the
<head>tag.
- for a javascript fallback, use yepnope.js - ensure it is part of the generated modernizr as well. Put the scripts in the
<script>
yepnope({
test : Modernizr.cssanimations,
yep : 'slides.css',
nope : 'slides.js'
});
</script>
[CSS3 + HTML5] Modernizr的更多相关文章
- CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局
原文:CSS3+HTML5特效8 - 顶部和右侧固定,左侧随窗口变化的布局 效果演示 实现原理 使用3个div(一个是顶部栏,一个是左侧栏,一个是右侧栏): 使用checkbox作为判断是否显示和隐藏 ...
- CSS3+HTML5特效9 - 简单的时钟
原文:CSS3+HTML5特效9 - 简单的时钟 效果演示(加快了100倍) 实现原理 利用CSS3的transform-origin 及 transform 完成以上效果. 代码及说 ...
- js+css3+HTML5拖动滑块(type="range")改变值
最近在做一个H5的改版项目,产品和设计给出的效果中有一个拖动滑块可以改变输入值的效果,类似如下图这样: 拿到这样的设计稿后,我有点懵了,自己写一个js?去网上找一个这样的效果?自己写一个可以,只是实现 ...
- 超酷 CSS3/HTML5 3D 飘带菜单实现教程
今天我们来介绍一款很有创意的CSS3/HTML5菜单,首先菜单是飘带形状的,看起来很优雅,这种菜单在个人博客中用的比较多,不仅干净利落,而且很具有个性化.另外,这款菜单在鼠标滑过菜单项时,将会出现3D ...
- 学习笔记 第十二章 CSS3+HTML5网页排版
第12章 CSS3+HTML5网页排版 [学习重点] 正确使用HTML5结构标签 正确使用HTML5语义元素 能够设计符合标准的网页结构 12.1 使用结构标签 在制作网页时,不仅需要使用< ...
- 8款强大的CSS3/HTML5动画及应用源码
1.CSS3 jQuery UI控制滑杆插件 今天我们要来分享一款基于CSS3和jQuery UI的控制滑杆插件,这款控制滑杆是在HTML5滑杆元素的基础上进行自定义CSS3渲染,所以外观更加漂亮.另 ...
- CSS3/HTML5实现漂亮的分步骤注册登录表单
分步骤的登录注册表单现在也比较多,主要是能提高用户体验,用户可以有选择性的填写相应的表单信息,不至于让用户看到一堆表单望而却步.今天和大家分享的就是一款基于HTML5和CSS3的分步骤注册登录表单,外 ...
- CSS3&HTML5各浏览器支持情况一览表
http://fmbip.com/ CSS3性质(CSS3 Properties) 平台 MAC WIN 浏览器 CHROME FIREFOX OPERA SAFARI CHROME FIREFOX ...
- CSS3+HTML5实现块阴影与文字阴影
CSS 3 + HTML 5 是未来的 Web,它们都还没有正式到来,虽然不少浏览器已经开始对它们提供部分支持.本教程分5节介绍了 5 个 CSS3 技巧,可以帮你实现未来的 Web,不过,这些技术不 ...
随机推荐
- c#读取通达信历史数据的方法
public Bar ReadBarMin(BinaryReader br, int instrumentId, long size) { int date = br.ReadUInt16(); in ...
- Hive学习之五 《Hive进阶—UDF操作案例》 详解
hive—UDF操作 udf的操作过程: 在HIVE会话中add 自定义函数的jar文件,然后创建function,继而使用函数. 下面就以下面课题为例: 课题:统计每个活动的PV和UV 一.Java ...
- interrupt & storage & DMA
1.Interrupt: The occurrence of an event is usually signaled by aninterrupt from either the hardware ...
- oracle触发器应用
首先给大家推荐两篇我看后的博文,我已经内容转载过来: 1.对触发器的讲解 本篇主要内容如下: 8.1 触发器类型 8.1.1 DML触发器 8.1.2 替代触发器 8.1.3 系统触发器 8.2 创建 ...
- JS 日常
判断一个字符串是否在另一个字符串里面 var str = 'bblText'; if(str.indexOf("Text") > 0) alert("包含了Tex ...
- HTML5 input控件 placeholder属性
placeholder 属性提供可描述输入字段预期值的提示信息(hint),该提示会在输入字段为空时显示,并会在字段获得焦点时消失. <input placeholder="请输入姓名 ...
- Linux bash重拾 2016-8-16
bash支持的引号: "" 双引号:弱引用,可以实现变量替换(变量会替换为值) [root@localhost ssh-6Xolw4LLAMwe]# echo "dire ...
- 资料Link集合
Spark RDD API详解(一) Map和Reduce| scala中Iterator的比较| 使用sbt构建scala应用| sbt常用命令| sbt更改默认ivy仓库位置| linux手动安 ...
- TableView_编辑 实例代码
@interface MJViewController () <UITableViewDataSource, UITableViewDelegate> { NSMutableArray * ...
- Caffe Python特征抽取
Caffe Python特征抽取 转载 http://www.cnblogs.com/louyihang-loves-baiyan/ Caffe大家一般用到的深度学习平台都是这个,关于Caffe的训练 ...