How to make Css--better (Series II)

Source: Internet
Author: User

The previous article (How to make Css--beter series one) analyzes what kind of code is efficient and what kind of code should be avoided, so what kind of code is easier to extend? What code is better to maintain? What code is better?

Let's just talk about the efficient code. If the style of the input type on the registration and login page is the same now, what should I do? Registered outer container for REG login The outer container is login so trust me.

. Input-user { This is a property } General and registration and login  or. log. Input-user{ This is the property }. reg. input-user{ This is the property }

We prefer the generic code (because it's the same), why write it two times?

This is a better code.

So if the code is better maintained, please come out three mysterious guest (semantic css, and annotations, the last powerful modular CSS).

A brief introduction (1) semantics is what you write CSS to see what is written if you have a lot of code to write is AAA BBB CCC or CSDB and so on, you will feel upset. Suggest direct English alphabet to write

Like what

Input-user He's talking about the input tag that fills in the user's name.

Input-password that is to fill in the user name password that input tag and so think a bit long can take the abbreviation but to let others can see you write this thing is what things can not be abbreviated to I-P at least also want to input-pwd kind of

Let's talk about (2) Comments We all know that we may have a site on a home page written in a index.css ordinary site may also be more than hundreds of lines of the problem is not very big if it is e-commerce? How about thousands of lines? It is recommended to write a note indicating that the following code is placed there in this case we implemented the module in the CSS file if you want to rebuild the sidebar later I can directly delete your code or rewrite it, there is no need to continue to find a page to write code (maybe there is a style conflict)

The Last is (3) modular modularity is simply to put your CSS into modules to deal with, for example, your reset.css may not change in ten years, so just put it in a new folder to save your page CSS as for the modular CSS I don't have to say the time is limited we can straight Baidu Modular CSS selection to fit their own modular structure

This is the younger brother's modularity may be some simple because this project is very small can not give more pictures .... Hey...

How to make Css--better (Series II)

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.