CSS preprocessing less basic use, CSS preprocessing less use

Source: Internet
Author: User

CSS preprocessing less basic use, CSS preprocessing less use
APIhttp: // lesscss.cn variable @ variable name: variable value @ maincolor: # aeeeee; @ acolor: # ffffff; @ ht200: 200px; @ ht50: 50px; @ wh980: 980px; @ lht50: 50px; application header nav {background-color: @ maincolor; width: @ wh980; height: @ ht50;} compile header nav {background-color: # aeeeee; width: 980px; height: 50px;} Effect

 

Definition class. BRradius (@ radius: 5px) {border-radius: @ radius;} application header nav {background-color: @ maincolor; width: @ wh980; height: @ ht50; /* or */. BRradius ;. BRradius (10px);} compile header nav {background-color: # aeeeee; width: 980px; height: 50px; border-radius: 10px;} Effect

 

Nested rule // nested syntax header {// define less local variable // perform four arithmetic operations @ navcolor: @ maincolor-#111; width: 1024px; margin: 0 auto; nav {background-color: @ navcolor; width: @ wh980; height: @ ht50 ;. BRradius (10px); ul {list-style: none; li {float: left; width: 100px; line-height: @ lht50; a {color: @ acolor; text-align: center; text-decoration: none; display: block; // Add & resolve the same level element or this element pseudo Class &: hover {background-color: #8 DEEEE ;}}}}}} Page <! DOCTYPE html>  

Compile less

1. browser compilation less

Download less. min

<Script type = "text/javascript" src = "js/less. min. js"> </script>

2. nodejs Compilation

Http://www.nodejs.cn official site in the environment variables to add installation path using node installation and compilation less by command npm install less-g Global installation less use lessc command for less file compilation format: generate the css file directory for the target file directory of lessc

 

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.