Monday, October 18, 2010

Out errors to make your writing more efficient CSS



According to some CSS experience in writing, how to improve rendering efficiency and consumption of resources by occupation, we come to look at CSS rendering of the efficiency of writing efficient CSS.

1, hexadecimal color value of the median and the case

Write hex color value you may use lower-case letters or omitted into 3-digit, no wording on it to find concrete data to prove the efficiency of the browser's rendering is affected, but the hexadecimal value of the default standard color is capitalized and 6-digit mark. In unknown circumstances, do not want to risk the lower the efficiency of rendering.

* Do not agree-color: # f3a;

* Suggested-color: # FF33AA;

2, display the differences with the visibility

They are used to set or retrieve the display object. display hidden object does not retain the physical space, visibility reserved for the hidden objects occupy the physical space. When the browser rendering of physical space to be occupied, there will be consumption of resources.

* Do not agree-visibility: hidden;

* To use the-display: none;

3, border: none; and border: 0; the difference between

And display a similar relationship with the visibility were not retained and reserved space. More of a border: 0; despite the border to hide out, but it will for you to retain the right to use border-color/border-style.

* Do not agree-border: 0;

* To use the-border: none;

4, should not be too small background image tile

A background image 1px wide and high, although the file size is very small, rendering high-500px wide plate need to repeat the tile 2500. Improve the efficiency of the background image rendering with the image size and volume, and the maximum image file size for about 70KB.

* Do not agree - Wide high 8px below the background image tile

* The proposed use - medium size and measure the background image size

5, IE filter

IE filter in addition to consumption of resources has more compatibility issues. Among them, to make a transparent PNG filter, GIF or JPG can be used through non-transparent approach seems to avoid the use of this filter. Proposed that only a transparent GIF in IE6 applications, because IE7 has support PNG transparency above.

* Do not agree, abuse of consumption of resources as IE filters also have compatibility problems.

* To use, the best choice to use other methods to avoid filters.

6, * (margin: 0; padding: 0;) to avoid differences in browser style

* Is wildcard for all tags are initialized again, the browser's rendering consumes certain resources. Some of the label in the different browsers is almost no difference, or some have been deprecated tag (because you do not use it), they do not need to re-initialize the wildcard again this can save a little resources.

* Do not support the use of wildcard asterisk

* Do not agree, divspanbuttonbtable tag into a wildcard such as internal and external control of fill styles

* To use, to selectively control the use of wildcards within and outside the fill style.

7, do not add additional labels to describe the class or id

If you have a selector based on id as the key selector, do not add the extra tag name up. Because the ID is the only, do not exist for a reason not reduce the efficiency of matching.

* Do not agree-button # backButton ()

* Does not support -. menu-left # newMenuIcon ()

* Suggested - # backButton ()

* Suggested - # newMenuIcon ()

8, try to choose the most specific class to hold the selector

Reduce the efficiency of the system one of the largest class in the label because we used too much of the selector. By adding a class to the elements, we can be subdivided into categories of class type, so no need to waste time on a label too many choices to meet the match.

* Do not agree-treeitem [mailfolder = "true"]> treerow> treecell ()

* Suggested -. treecell-mailfolder ()

9, to avoid children and grandchildren selector

Children CSS selector is the most consumed resources selector. He is very resource intensive, especially in the tag selector to use when the class or general class. In many cases, we really want is the child selector. Unless clearly stated, is strictly prohibited in UICSS descendants selector of.

* Do not agree-treeheadtreerowtreecell ()

* Better, but still not work (see next)-treehead> treerow> treecell ()

10, the label should not contain sub-class selectors

Do not use the sub-tag class selectors. Otherwise, each element in the emergence of an additional increase would match the time. (Especially when the selector seems to mostly be matched case)

* Do not agree-treehead> treerow> treecell ()

* Suggested -. treecell-header ()

11, note the use of all child selector

Careful use of child selector. If you can not think of a way to use him, then do not use. Especially in the RDF tree and the menu will often use child selectors, like this.

* Do not agree-treeitem [IsImapServer = "true"]> treerow>. Tree-folderpane-icon ()

Remember RDF properties can be copied in the template! Advantage of this, we can copy those who want to change the child based on the attributes of RDF XUL element attributes.

* Suggested -. tree-folderpane-icon [IsImapServer = "true"] ()







Recommended links:



QuickTime to MPG



Shi Jian: create Their own aviation nerve



Traditional TV will not "give way" on the computer?



Ambiguous "message" mostly Huafei trap



Compare Accounting And Finance



Wang Zhuo from good to Great



OGM To AVI



Several Important concepts of object-oriented [1]



Essays on CMMI [1]



How I sold 1,000 cars, 200 sets of villas



Kunming, Yunnan Province ASRock core agent signing



Magcore.dll Error Repair It



Using VMware, vowed to COMPUTER "cloned a technique"



brief Audio Presentation Tools



MPG to AVI



No comments:

Post a Comment