(i) Building projects with Less+gulp+requirejs (learn less)

Source: Internet
Author: User

Conclusion of the project:

Company website refactoring, the whole station need to rewrite, and finally have the opportunity to contact Less,gulp and Requirejs, because the previous job is to write a few activity pages, and no opportunity to use these tools, nonsense not to say, first look at the completion of the project directory:

is less file directory, according to the function is very fine, there is head, bottom, popup box, button, color ..... And so on, the benefits of this writing are many, later easier to maintain, easy to modify, and the structure is clear.

I first write a few commonly used less features, want to know more can go to the official website, very simple.

Because it is a demonstration, I do not need to gulp tools, I use the Webstorm has the automatic compilation function.

1. Nesting: can save a lot of time

Less supports nested style classes (2)

Figure 1:

Figure 2:

2. Variables

Commonly used in defining global variables such as color, etc.;

Figure 3:

3. Parameters

Figure 4:

4. Nesting without parameters (note the difference from Figure 2)

Figure 5:

5. Pattern matching and guided expressions

In some cases, we want to change the default rendering of a mix based on the parameters passed in, such as the following example:

Figure 6:

:

6 Less custom functions: lighten darken Fadein fadeout ... Wait a minute

7.when (lightness (@a) returns the brightness percentage of the color)

Specific functional area on the official website to see very detailed ~ ~

Go to dinner first, come back.

(i) Building projects with Less+gulp+requirejs (learn less)

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.