当前位置:

web 前端开发注意事项

684 views2010-03-25无人留言

4. Javascript

* Don’t use jQuery in widgets that will end up on other sites.
不要在组件中使用jquery

* Otherwise, use jQuery.
否则使用 jquery

* Whenever possible, put Javascript at the bottom of the page.
尽量把 js放在页面最后

* Don’t use inline Javascript.
不要直接在页内书写js

5. HTML/CSS

* Add a top level ID to every kind of page (#race-page, #candidate-page)
给每个类型的页面定义顶级的id(如 body id=”aboutus-page”)

* Use IDs for elements that are unique to every page in the site. Use classes for everything else.
ID 在页内是唯一的,class 可以重复使用。

* Use hyphens for IDs and classes, no camelCase or underscores.
在 ID 和 Class 中使用-(减号,连字符)而不是下划线,或者首字符大写。

* Use descriptive and unique names for IDs. Use simple generic names for classes.
使用描述性的名字作为ID,简单通用的名字做class

* Always define classes with nested rules: #candidate-page .box-column .box .bar-chart. Use your best judgment, don’t go overboard with the nested rules, just enough to make sure your not going to style the wrong things. IDs rarely need to be nested
尽量使用嵌套规则(限制伪类作用域),如 #candidate-page .box-column .box .bar-chart,但不要太长。ID 一般不需要嵌套规则。

* Each CSS selector gets its own line. The block of rules has to share. It makes big CSS scannable:
每个CSS 规则单独一行,如

a:link {color:#336699;}
a:hover,
a:active {color:#6d9fd2;}
a:visited {color:#336699;}
a:visited:hover {color:#6d9fd2;}

* Don’t rely on (because of IE6):
如果用户使用ie6的话,要慎用下面的样式

o min-width, max-width, min-height, max-height
o overflow:hidden
o css tables
o attribute selectors
o psudo-classes (other than for a tags)
o > (child selector)
o position:fixed

* If you are positioning one block absolutely inside another, make sure the parent has a specified size.
绝对定位的父级元素要有明确尺寸。

* Don’t use inline styles.
不要直接在页面内写(内联)样式

6. Images

* Don’t use them.
尽量不要用图片

* If you use them, make sure you use photoshop’s “Save for web…” or figure out another way to optimize them.
即便用,也应该用ps优化

* Use jpeg for images with lots of different colors and gradients, png/gif for images with few colors.
颜色多,有渐变效果的使用 jpeg,颜色少使用 gif 或者 png

* PNG rules (if you’re relying on PNG fix)

o Don’t use PNGs. If it hurts, blame Microsoft.尽量不要使用png
o If you use PNGs, don’t use PNGs with alpha 尤其是透明png
o If you use PNGs with alpha, use them in img tags only. 如果透明png尽量直接 img src=
o If you use PNGs with alpha as background images: 如果使用透明png做背景,需要手工或者js处理为 filter alphaImageLoader

http://24ways.org/2007/supersleight-transparent-png-in-ie6

via Best practices in web development with Python and Django

 
类别:
除非特殊说明,本站文章均为鹏讯科技版权所有,转载请注明出处。
如本站引用的文字、图片、其它媒体等侵犯了您的权益,请及时告知,我们将会在第一时间删除。

发表评论:

姓名:

邮件:

网址:


当前用户: validated XHTML 1.0 - CSS 3 - Section 508 - PR
Copyright © 2005-2010 陕西鹏讯科技 版权所有