Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
Autoprefixer解析CSS文件并且添加浏览器前缀到CSS规则里,使用Can I Use的数据来决定哪些前缀是需要的。
所有你需要做的就是把它添加到你的资源构建工具(例如 Grunt)并且可以完全忘记有CSS前缀这东西。尽管按照最新的W3C规范来正常书写你的CSS而不需要浏览器前缀。像这样:
1
2
3
|
a{ transition :transform 1 s } |
Autoprefixer使用一个数据库根据当前浏览器的普及度以及属性支持提供给你前缀:
1
2
3
4
5
|
a{ -webkit-transition :-webkit-transform 1 s; transition :-ms-transform 1 s; transition :transform 1 s } |
问题
- 当前浏览器列表以及它们的普及度。
- 新CSS属性,值和选择器前缀列表。
- 主流浏览器最近2个版本用“last 2 versions”;
- 全球统计有超过1%的使用率使用“>1%”;
- 仅新版本用“ff>20”或”ff>=20″.
1
2
3
4
5
6
7
|
a { background : linear-gradient(to top , black , white ); display : flex } ::placeholder { color : #ccc } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
a { background : -webkit-linear-gradient( bottom , black , white ); background : linear-gradient(to top , black , white ); display : -webkit-box; display : -webkit-flex; display : -moz-box; display : -ms-flexbox; display : flex } :-ms-input-placeholder { color : #ccc } ::-moz-placeholder { color : #ccc } ::-webkit-input-placeholder { color : #ccc } ::placeholder { color : #ccc } |
1
2
3
4
|
a { -webkit-border-radius : 5px ; border-radius : 5px } |
1
2
3
|
a { border-radius : 5px } |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Gruntfile.js module.exports = function (grunt) { grunt .initConfig ({ autoprefixer : { dist : { files : { 'build/style.css' : 'style.css' } } }, watch : { styles : { files : [ 'style.css' ], tasks : [ 'autoprefixer' ] } } }); grunt.loadNpmTasks( 'grunt-autoprefixer' ); grunt.loadNpmTasks( 'grunt-contrib-watch' );}; |
style.css
到 build/style.css
. 同样我们将用 grunt-contrib-watch
来
监听style.css文件变化
重新编译build/style.css。
1
2
3
|
a { width : calc(50% - 2em) } |
calc()
值单元需要Safari 6的浏览器前缀。
1
2
3
4
|
a { width : -webkit-calc( 50% - 2em ); width : calc( 50% - 2em ) } |
1
2
3
4
|
a { width : calc( 50% - 2em ); transition : transform 1 s } |
transition
及transform
添加
前缀。但IE9也需要为transform添加前缀,作为transition的值。
1
2
3
4
5
6
7
|
a { width : -webkit-calc( 1% + 1em ); width : calc( 1% + 1em ); -webkit-transition : -webkit-transform 1 s; transition : -ms-transform 1 s; transition : transform 1 s } |
Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序的更多相关文章
- 转:[译]Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
原文来自于:http://www.cnblogs.com/aNd1coder/archive/2013/08/12/3252690.html Autoprefixer解析CSS文件并且添加浏览器前缀到 ...
- [译]Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
Autoprefixer解析CSS文件并且添加浏览器前缀到CSS规则里,使用Can I Use的数据来决定哪些前缀是需要的. 所有你需要做的就是把它添加到你的资源构建工具(例如 Grunt)并且可 ...
- 浏览器前缀-----[译]Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
Autoprefixer解析CSS文件并且添加浏览器前缀到CSS规则里,使用Can I Use的数据来决定哪些前缀是需要的. 所有你需要做的就是把它添加到你的资源构建工具(例如 Grunt)并且可 ...
- Autoprefixer:一个以最好的方式处理浏览器前缀的后处理程序
Autoprefixer解析CSS文件并且添加浏览器前缀到CSS规则里,使用Can I Use的数据来决定哪些前缀是需要的. 所有你需要做的就是把它添加到你的资源构建工具(例如 Grunt)并且可 ...
- [译]Autoprefixer:用最可行的方式处理浏览器前缀的CSS后处理器
Autoprefixer,通过Can I Use数据库来确定哪些浏览器前缀是需要的,然后解析CSS文件,将前缀添加到CSS规则里. 你所要做的就是添加你的资源构建工具(比如:Grunt),然后你就可以 ...
- autoprefixer安装或者里sass的$mixin处理浏览器前缀
Autoprefixer是一个后处理程序,不象Sass以及Stylus之类的预处理器.它适用于普通的CSS,可以实现css3代码自动补全.也可以轻松跟Sass,LESS及Stylus集成,在CSS编译 ...
- 使用selenium时,使用从系统启动浏览器与通过自动化驱动方式启动浏览器控件ID不一样解决方法
最近遇到一个怪事,通过正常打开浏览器,按照正常的web登录然后点击进入系统流程,将各控件的ID识别成功,然后使用 python3+selenium写好脚本,高高兴兴的用脚本跑时老是提示找不到控件,然后 ...
- hbuilder和sublime的autoprefixer安装或者里sass的$mixin处理浏览器前缀
Autoprefixer是一个后处理程序,不象Sass以及Stylus之类的预处理器.它适用于普通的CSS,可以实现css3代码自动补全.也可以轻松跟Sass,LESS及Stylus集成,在CSS编译 ...
- [No000040]取得一个文本文件的编码方式
using System; using System.IO; using System.Text; /// <summary> /// 用于取得一个文本文件的编码方式(Encoding). ...
随机推荐
- octave学习
前置安装 octave introduction 杂 clear; close all; clc刷新清空octave 如果写程序后缀名.m help commandname帮助 ;用法同c++ %注释 ...
- redis批量删除脚本
服务器上安装了redis客户端,通过客户端利用脚本对数据批量删除,脚本内容如下: #!/bin/bash name="$1" echo $name ./redis-cli -h r ...
- RocketMq使用注意事项
Topic 一个Topic是一个主题.一个系统中,我们可以将消息划成Topic,这样,将不同的消息发送到不同的queue. Queue 一个topic下,我们可以设置多个queue,每个queue就是 ...
- 【HDOJ1828&&POJ1177】Picture(线段树,扫描线)
题意:给定n个矩形,求他们的并的周长 n<=5e3,abs(x[i])<=1e4 思路:From https://www.cnblogs.com/kuangbin/archive/2013 ...
- C#中Hashtable的用法 转
原文发布时间为:2009-04-14 -- 来源于本人的百度文章 [由搬家工具导入] 一,哈希表(Hashtable)简述 在.NET Framework中,Hashtable是System.Coll ...
- [LeetCode] Valid Number 确认是否为数值
Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => ...
- AC日记——【模板】KMP字符串匹配 洛谷 3375
题目描述 如题,给出两个字符串s1和s2,其中s2为s1的子串,求出s2在s1中所有出现的位置. 为了减少骗分的情况,接下来还要输出子串的前缀数组next.如果你不知道这是什么意思也不要问,去百度搜[ ...
- DOM-window下的常用子对象-location-刷新页面
1.刷新当前页面:(通过给location.href赋值的方式) window.location.href="" eg:window.location.href="htt ...
- GCJ——Crazy Rows (2009 Round 2 A)
题意: 给定一个N*N的矩阵,由0,1组成,只允许交换相邻的两行,把矩阵转化为下三角矩阵(对角线上方全是0),最少需要多少次交换?(保证可以转化为下三角矩阵) Large: N<=40 解析: ...
- noip2017集训测试赛(三)Problem C: MST
题面 Description 给定一个n个点m条边的连通图,保证没有自环和重边.对于每条边求出,在其他边权值不变的情况下,它能取的最大权值,使得这条边在连通图的所有最小生成树上.假如最大权值为无限大, ...