什麼時候css會見less

來源:互聯網
上載者:User

標籤:

在一定程度上,css不能被視為一個節目。雖然和其他語言,它有自己的規範。編碼,但它的笨拙實在讓我失望。

不喜歡css是由於不管怎麼最佳化代碼。項目大到一定程式後。都會看上去一團亂。並且有時候一個bug的定位也要花去不少時間。直到我發現了less。突然感慨。css中的jquery大概就是它了。

less同意傳參數,同意定義變數,能夠把層疊的樣式組織得較為美觀,能夠少寫很多反覆代碼……這一切的優勢,讓我毫不猶豫地要去把它增加接下來的項目。

舉個範例:

css要這樣寫:

#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能夠這樣寫:

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


css要這樣寫:


#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能夠這樣寫:

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


以下是學習它的一些資料:


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

2、高速 新手教程:http://www.bootcss.com/p/lesscss/

3、在ie6/7/8下使用less。須要加上es5-shim.js。:https://github.com/yumucode/es5-shim


剛在ie6下測試,使用http://localhost/test/less/會抱錯,來不及查原因。而http://localhost/test/less/index.php則不會報錯。比較理想的做法是不讓瀏覽器執行less.js,而是在頭版輸出,把.less檔案轉化成.css檔。

著作權聲明:本文博主原創文章。部落格,未經同意不得轉載。

什麼時候css會見less

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.