This article mainly introduces the performance optimization of CSS writing and the recommendation summary of High Maintenance optimization, including the hot discussion points such as Sprite chart and size setting, the friends who need can refer to the following
Performance, the word is now fired very hot, but also every developer, from the "Know", "will do" after a "how to do" stage. Performance is about the user's experience in different devices an
to code confusion and cause unexpected side effects on attribute values.
Not recommended
width:100px;margin:0 auto;
Recommendation
width:100px;margin-right:auto;margin-left:auto;The Unit after 0 is omitted.
Do not use units after 0 values.
Not recommended
padding-bottom: 0px;margin: 0em;
Recommendation
padding-bottom: 0;margin: 0;Color value in hexadecimal notation
The color values in css can be expressed
Sample Code for dynamically loading and removing js/css files and css sample code
This article briefly introduces how to dynamically load, remove, and replace js/css files. Sometimes, when we write the front-end, there will be a need to dynamically load some East such as
is no suitable solution, remember to write a CSS file to these specific browsers, do not mix compatible code and regular code, so that the maintenance of code, if later do not support these old browser, You can delete these individual CSS files directly.1 6, remember the di
A drop-down menu example of "proficient in CSS" and "proficient in css"
This example is from the drop-down menu. I have made some changes, and the principle is indeed very simple, but the author's code has a clear sense of attention and is worth learning. In addition, the au
Backend code farmers front-end (CSS) Lesson 3: Selector and css SelectorI. selector 1. ID selector:
Syntax:First, there is a # sign in front of the ID selector, also known as the checkboard number or well number.See the following rules:
*#intro {font-weight:bold;}
Like a class selector, the wildcard selector can be ignored in the ID selector. The previous
CSS and other proportional division, in the CSS layout is more important, the following share several common methods and explore compatibility.
One: Floating layout + percent
The code is as follows
Copy Code
Emmet HTML code: ul.float-ul>li*5>.co
css| Tips | Optimize skin CSS files that have recently been seen by many netizens and found that they have a lot of redundant code. Let me tell you about how to clear these redundant code to make your CSS file more concise.
First, margin, padding properties
Referring to the
10 very good CSS code formatting tools recommended, very good css
If you are learning CSS at the beginning, it means that many of your code or structure may need to be optimized. For example, you may have used classes too much, ad
+ inline style) Final Result
Yes
Yes
No (just inline style)
How to obtain attributes: style. name and style [name]
Supported (except for the "filter" attribute)
Supported
Supported
Supported methods to obtain CSS attribute values
GetPropertyValue
IE8-only getAttribute is supported; IE9 + supports getPropertyValue and get
block-level elements is block, while the line element is inline. You can redefine display to convert block-level elements and line-level elements. However, remember that the following css styles are invalid for the row elements: width height and the margin padding set in the vertical direction, so avoid defining these useless styles for the row elements.7. Remember the weight defined by
HTML file: prefix with a single letter + "-". for Example: for the header part, we can write this:
1
divclass="g-header">div>
So what is a "single letter"? is actually the first letter of the layout (grid) in the CSS internal classification method that we have just introduced, and the advantage is that we can clearly know what the role is in the
the correct value. Note thatThe Dom attribute quotation marks are optional., AndThe CSS attribute must contain quotation marks because the attribute name contains a hyphen-.
When you use .css () to set a style,Jquery changes the style property of an element.For example, the following two lines of code are equivalent:
The function and significance of CSS code optimization
1, reduce the consumption of page bytes. Shorten the time that the browser downloads CSS code under the same conditions, which is equivalent to speed up the page opening
2, easy to maintain. Simplify and standardize CSS
There are three types of CSS written in the format
Inline style: meaning to write styles within a row
For example, say
Applies only to
inline style : Use style to unload all styles inside the style.
For example, say:
Outreach Style : The pop point is the external styl
{ padding:15px ; /*border:1px solid #222; */}/* Don ' t */p { padding:15px; border:1px solid #222; }
Using Kebab-case to name variables
The name of the style class or ID name needs to be added between multiple words-the symbol, the CSS itself is case insensitive so you can not use CamelCase, on the other hand, long ago also does not support the underscore, so now the default naming method is to use-:
/* Do */.footer-column-left {}/
follows the same style as the one after the previous point.
The output is as follows:
Eight. (Selector mix) selector grouping (Grouping):
Syntax: E1.E2.E3 Description: 1. Common type selectors and class selectors; format: HTML element name. class selector name, no spaces in the middle
2. Other options and include selectors; the most common way to use
Example: As the name implies, Chaos is used together, and the rules are the same.
The output is as
selector##CSS is a declarative language that you can use to specify styles for DOM elements. In this language, some rules take precedence over other rules, just as inline styles rewrite some of the previous rules.For example, if we have the following HTML and CSS code: =
We are in the front-end development of the Web page, in order to make the site visually more beautiful, the effect is more rich, the powerful nature of CSS is essential. So here's a reference to a property that we often use when developing a Web page, CSS Display properties. Display properties are supported by all major browsers. Second, we all know that the display property specifies the type of box the el
: 10px; * padding-top: 0; padding-bottom: 13px; * padding-bottom: 0; Height: 36px; Background: URL (images/button.gif) No-repeat right-36px; text-Decoration: none; font-size: 12px; color: # FFF ;}
We first set the display: inline-block, and then we use padding to open its margin so that it has some space to fill the image. Note that the image path here is replaced with your own path. Set other styles, such as removing the underline, font color, and fo
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.