|
1 2 3 4 5 |
/* * @description: xxxxx中文说明 * @author: zhifu.wang * @update: zhifu.wang (2012-10-17 18:32) */ |
|
1 2 3 |
/* module: module1 by zhifu.wang */ … /* module: module2 by zhifu.wang */ |
模块注释必须单独写在一行
|
1 |
/* this is a short comment */ |
单行注释可以写在单独一行,也可以写在行尾
|
1 2 3 4 |
/* * this is comment line 1. * this is comment line 2. */ |
多行注释必须写在单独行内
|
1 2 |
/* TODO: xxxx by zhifu.wang 2012-10-18 18:32 */ /* BUGFIX: xxxx by zhifu.wang 2012-10-18 18:32 */ |
用于标注修改、待办等信息
|
1 2 3 |
div.test { width: 100px; height: 200px; } a:focus, a:hover { position: relative; right: 1px; } |
|
1 |
-webkit- / -moz- / -ms- / -o- /
std |
|
1 2 3 4 5 6 |
div.animation-demo { -webkit-animation: mymove 5s infinite; -moz-animation: mymove 5s infinite; -o-animation: mymove 5s infinite; animation: mymove 5s infinite; } |
除16进制颜色和字体设置外,CSS文件中的所有的代码都应该小写。
|
1 2 |
.red { color: red }(错误) .important-news { color : red }(正确) |
|
1 2 3 4 |
div { width: 200px; font-size: 16px; } |
推荐的样式编写顺序
|
1 |
display/list-style/position/float/clear |
|
1 |
width/height/margin/padding/border |
|
1 |
background |
|
1 |
line-height |
|
1 2 |
color/font/text-decoration/text-align/ text-indent/vertical-align/white-space/content |
|
1 |
cursor/z-index/zoom |
|
1 |
transform/transition/animation/box-shadow/border-radius |
|
1 |
a:link -> a:visited -> a:hover
-> a:active(LoVeHAte) |
|
1 2 3 |
div > * {} ul > li > a {} body.profile ul.tabs.nav li a {} |
|
1 |
div#test { width: 100px; } |
|
1 2 3 4 5 |
h1 { color: black; } p { color: black; } –> h1, p { color: black; } |
|
1 2 |
background: color image repeat attachment position; font: style weight size/lineHeight family; |
font-size目前人人CSS取值的几种类型如下:
|
1 |
12px/9pt/1.2em/150%/1.7 |
现将font-size取值的单位类型约束如下:
目前font-family取值类型丰富多样,比如home-frame2-all-min.css中:
| body | Tahoma, Verdana, STHeiTi, simsun, sans-serif |
| .fselect-pager li a | Arial |
| a.mini-share | mingliu |
| .small | tahoma, mingliu |
| select, label, textarea, input | “lucida grande”, tahoma, verdana, arial, STHeiTi, simsun, sans-serif |
| .m-autosug small | MingLiU |
| #appsMenuPro .menu-apps-side a.add-app-btn | 宋体 |
| .site-footer .haoes | tahoma, mingliu |
为了对font-family取值进行统一,更好的支持各个操作系统上各个浏览器的兼容性,现将font-family统一约束如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
body { font: 12px Tahoma, Verdana, STHeiTi, simsun, sans-serif; }
input, |
重要原则:尽量少用hack,能不hack坚决不hack,不允许滥用hack。
如果需要使用hack,请参考以下hack方式:
| IE6 | * html selector { … } |
| IE7 | *+html selector { … } |
| 非IE6 | html>body selector { … } |
| firefox | @-moz-document url-prefix() { … } |
| safari3+/chrome | @media screen and (-webkit-min-device-pixel-ratio:0) { … } |
| opera | @media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) { … } |
| iPhone/mobile webkit | @media screen and (max-device-width: 480px) { … } |
| IE6 | _property: value |
| IE7 | +property: value |
| IE6/7 | *property: value |
| IE6/7/8/9 | property: value\9 |
目前人人页面中的弹层较多,z-index取值也比较随意,导致相互覆盖的情况,有的弹层直接覆盖了顶部导航条。
以下是首页的一些z-index取值比较大的属性设置统计:
| header头部导航条 | 1999 |
| 账号菜单 | 10001 |
| 通知提醒 | 10000 |
| 顶部搜索结果弹窗 | 10001 |
| 页面内容顶部/publisher | 1998 |
| publisher电影搜索提示 | 1000 |
| 用户等级与登录信息提醒 | 1999 |
| 回到顶部按钮 | 999 in css, 1001 in html |
| @ | 10001 |
| 表情 | 10001 |
| 名片卡 | 9999 |
| 底部工具条与webpager/radio | 1000 in css, 1999 in html |
| 照片浏览弹层 | 5000 |
| 照片多张上传弹层 | 3001 |
| XN默认弹层组件 | 10000 |
| 首页应用中心推荐弹层 | 1002 |
| HTML5拖拽上传 | 999998 |
其他z-index设置:
| .dropmenu-holder | 999999 |
| .appsMenuPro | 10001 |
| .search-Result | 10002 !important |
| .menu-dropdown | 200 |
| .site-nav .navigation | 981 |
| .mentionFrdList | 10002!important |
| .app-center-popup | 1002 |
| .feed-back-v6 | 1999 |
| #appcardcontent | 1998 |
| .feed-comment-attach | 1000 |
| .message-box | 1000 |
| #friendcreate-box | 100 |
这些z-index设置,极有可能造成相互覆盖,存在潜在的问题风险。例如:
因此,有必要对z-index取值进行规范和约束。避免前端开发人员为了自己开发的功能能够正确展示,而忽略了其他组件的展示需求。
如果要为弹层设置z-index,请务必按照给定的取值区间来进行设置。
这里只是初稿,可能还需要精确到某一个组件的z-index分配,需要大家集思广益(可以参考cookie的设置流程,在使用z-index时必须经过审批)
| 头部导航区域 | [1999 - 2100] |
| publisher所在的内容head区 | [1998] |
| 页面主要内容区域 | [-1 - 1997] |
| 页面底部 | [1999 - 2100] |
| 首页应用弹层 | [1000] |
| 全站公共组件 | [-1 - 1999] |
| 全页面蒙层弹窗组件 | [10000-11000] |
| 头 | header | 内容 | content | 尾 | footer | 导航 | nav |
| 子导航 | subnav | 栏目 | column | 主体 | main | 新闻 | news |
| 版权 | copyright | 文章列表 | list | 加入 | joinus | 合作伙伴 | partner |
| 标志 | logo | 侧栏 | sidebar | 横幅 | banner | 状态 | status |
| 菜单 | menu | 子菜单 | submenu | 滚动 | scroll | 搜索 | search |
| 标签页 | tab | 提示信息 | msg | 小技巧 | tips | 标题 | title |
| 指南 | guild | 服务 | service | 热点 | hot | 下载 | download |
| 注册 | regsiter | 登录条 | loginbar | 按钮 | btn | 投票 | vote |
| 注释 | note | 友情链接 | friend-link | 外套 | wrap | 面包屑 | bread-crumb |
| 当前的 | current | 购物车 | shop | 图标 | icon | 文本 | txt |
| 待补充… |
原文:http://www.cnblogs.com/jdsm/p/3522787.html