When css encounters less

Source: Internet
Author: User

When css encounters less

To some extent, css cannot be called a program. Although it has its own specifications and needs coding like other languages, it's clumsy and disappointing to me. I don't like css because no matter how code is optimized, after a project reaches a certain level, it will look messy. And sometimes it takes a lot of time to locate a bug. Until I find less. Suddenly, jquery in css is probably like it.

Less allows passing parameters and defining variables. You can organize cascading styles in a more elegant manner and write less repetitive code ...... All these advantages allow me not to hesitate to add it to the next project.

For example:

Css should be written like this:

#header h1 {  font-size: 26px;  font-weight: bold;}#header p {  font-size: 12px;}#header p a {  text-decoration: none;}#header p a:hover {  border-width: 1px;}


Less can be written like this:

#header {  h1 {    font-size: 26px;    font-weight: bold;  }  p { font-size: 12px;    a { text-decoration: none;      &:hover { border-width: 1px }    }  }}


Css should be written like this:


#menu a {  color: #111;  border-top: dotted 1px black;  border-bottom: solid 2px black;}.post a {  color: red;  border-top: dotted 1px black;  border-bottom: solid 2px black;}

Less can be written like this:

.bordered {  border-top: dotted 1px black;  border-bottom: solid 2px black;}#menu a {  color: #111;  .bordered;}.post a {  color: red;  .bordered;}


Below are some of its materials:


1. less. js:Http://www.lesscss.net/#download-options

2. Quick Start Tutorial:Http://www.bootcss.com/p/lesscss/

3,To use less in ie6/7/8, you must addEs5-shim.js,: Https://github.com/yumucode/es5-shim


In ie6, http: // localhost/test/less/may cause an error. Http: // localhost/test/less/index. php does not report an error. The ideal practice is not to allow the browser to run less.js, but to convert the .lessfile into a .css file before the page output.

Related Article

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.