这篇文章主要介绍了CSS Normalize文件配置示例,对全局项目进行设置,需要的朋友可以参考下
作为前端工程师,很多人都有自己的一套CSS Normalize文件,这样能省掉开发过程中的不少麻烦,提高工作效率。在前人的基础上,我总结了自己的CSS Normalize文件,目前基本上每个项目都有在使用中:
/*Normalize*/ *{margin:0;padding:0;list-style-type:none;} *html,*html body /* 修正IE6振动bug */{ background-image:url(about:blank); background-attachment:fixed; } body{ font-family:"Microsoft Yahei","Hiragino Sans GB" ,Arial,Lucida,Verdana,SimSun,Helvetica,sans-serif; /*font-size : 62.5%; px数值除以10,然后换上em作为单位*/ /*min-width:980px;*/ font-size:13px; } a,img{border:none;text-decoration:none;} a{blr:expression(this.onFocus=this.blur());} /*去掉a标签的虚线框,避免出现奇怪的选中区域*/ /*a:active {test:expression(target="_blank");}*/ :focus{outline:0;} label{cursor:pointer;} img{vertical-align:middle;} table{empty-cells:show;border-collapse:collapse;border-spacing:0;} h1{font-size:1.6em;}h2,h3,h4{font-size:1.4em;}h5,h6{font-size:1.2em;} input{border:none;} textarea{overflow:scroll;} a, input,textarea, .hover-delay { font-family:"Microsoft Yahei","Hiragino Sans GB", Arial,Lucida,Verdana,SimSun,Helvetica,sans-serif; -webkit-transition: all 0.3s ease-out; -moz-transition: all 0.3s ease-out; -ms-transition: all 0.3s ease-out; -o-transition: all 0.3s ease-out; transition: all 0.3s ease-out; } input.none-radius{ border-radius:0; -moz-border-radius:0; -webkit-border-radius:0; } input::-ms-clear{ display:none;} //去掉输入框的叉叉 .clear{clear:both;} .txt-indent{text-indent:-999px;overflow:hidden;} input[type=text],input[type=tel],input[type=email]{ -webkit-appearance: none; box-shadow: none;} /*Normalize end*/
对与我的实际使用中,我有一个Template文件夹(最近新增了一个针对Mobile)
里面的文件夹大致分为如下:
1)images: 存放项目中的图片(里面又会根据项目模块进行文件夹划分)
2)css: 存放css文件(里面会有一个base.css文件,预置上文中的css normalize)
3)js:存放js文件,里面还有一个vender的文件夹,存放插件js(例如:jQuery库),外面有main.js(主要js文件),plugins.js(插件引用的js)
根目录下,为index.html文件
主要为如下文件:
<!doctype html> <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> <!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> <!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> <head lang="zh-CN"> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>xxx</title> <meta name="keywords" content="xxx" /> <meta name="description" content="xxx" /> <link rel="shortcut icon" href="images/favicon.ico" /> <!-- IE address前ico图标 --> <link rel="stylesheet" href="css/normalize.css" /> <!-- reset style --> <link rel="stylesheet" href="css/base.css" /> <!-- basic style --> <script src="js/vendor/jquery-1.10.2.min.js"></script> <!-- jQuery library --> <script src="js/vendor/jquery-ui-1.11.1.js"></script> <!-- jQuery UI library --> <script src="js/main.js"></script> <!-- main js --> <script src="js/plugins.js"></script> <!-- plugins --> <!--[if (gte IE 6)&(lte IE 8)]> <script type="text/javascript" src="js/vendor/selectivizr.js"></script> <noscript><link rel="stylesheet" href="[fallback css]" /></noscript> <![endif]--> <!--/*修正CSS3在IE6-8*/--> <!--[if lt IE 9]> <script src="js/html5.js"></script> <![endif]--> </head> <body> <!--wrapper--> <p class="wrapper"> <!--header--> <p class="header"> <!--logo--> <p class="logo"></p> <!--logo end--> <!--navigation--> <p class="nav"> </p> <!--navigation end--> <!--banner--> <p class="banner"> </p> <!--banner--> </p> <!--header end--> <!--container--> <p class="container"> <!--news--> <p class="news"> </p> <!--news end--> <!--sidebar banner--> <p class="sidebar"> </p> <!--sidebar banner end--> <!--hot top9--> <p class="hot"> </p> <!--hot top9--> </p> <!--container end--> <!--footer--> <p class="footer"> <!--about us--> <p class="about-us"></p> <!--webchat--> <p class="webchat"></p> <!--copyright--> <p class="copyright"></p> </p> <!--footer end--> </p> <!--wrapper end--> </body> </html>
Mobile下的head会有如下meta设置:
<meta name="viewport" id="viewport" content="width=device-width, initial-scale=1, user-scalable=no" /> <meta name="apple-mobile-web-app-capable" content="yes" /> <meta name="apple-touch-fullscreen" content="yes" /> <meta name="apple-mobile-web-app-status-bar-style" content="black" />
值得一提的是,在github上也有做了一个 normalize.css 文件,我在做HTML5项目也将其应用在normalize中。
另外,对于很多开发中来说,Template文件同样是节省了不少写重复代码的时间,同时,又规范了自己的书写习惯。
以上就是本文的全部内容,希望对大家的学习有所帮助,更多相关内容请关注PHP中文网!
相关推荐:
以上是关于CSS Normalize的文件配置的详细内容。更多信息请关注PHP中文网其他相关文章!

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

Atom编辑器mac版下载
最流行的的开源编辑器

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具