CSS中的BEM命名

來源:互聯網
上載者:User

標籤:emd   htm   三級   之間   element   pre   團隊   如何   同名   

BEM是一個非常有用,強大,簡單的命名規範。

它能讓前端代碼更容易閱讀和理解,更容易協作,更容易控制,更加健壯和明確而且更加嚴密,更加容易地維護代碼。

 

BEM命名思路:

.block{}.block__element{}.block--modifier{}
.block{}.block__element{}.block--modifier{}
著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.com

命名規範的模式如下:

.block{}.block__element{}.block--modifier{}
著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.com

命名規範的模式如下:

.block{}.block__element{}.block--modifier{}
著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.com

 

Block

將所有東西都劃分為一個獨立的模組。

一個header是block,header裡嵌套的搜尋方塊是block,甚至一個icon一個logo也是block,

block可以相互嵌套。

 

Element

一個Block下的所有Element無論相互層級如何,都要攤開扁平的屬於Block。

所以 BEM 最多隻有 B+E+M 三級,不可能出現 B+E+E+..+E+M 超長class名,也要求E不能同名。

 

Modifier

.current .active 等表達狀態

讓所有東西之間的聯絡變得更加緊密,讓團隊甚至是你個人都能夠更加容易地維護代碼著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.comBEM的意思就是塊(block)、元素(element)、修飾符(modifier),是由Yandex團隊提出的一種前端命名方法論。著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.comBEM的意思就是塊(block)、元素(element)、修飾符(modifier),是由Yandex團隊提出的一種前端命名方法論。著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.comBEM的意思就是塊(block)、元素(element)、修飾符(modifier),是由Yandex團隊提出的一種前端命名方法論。著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.comBEM的意思就是塊(block)、元素(element)、修飾符(modifier),是由Yandex團隊提出的一種前端命名方法論。著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.comBEM的意思就是塊(block)、元素(element)、修飾符(modifier),是由Yandex團隊提出的一種前端命名方法論。著作權歸作者所有。
商業轉載請聯絡作者獲得授權,非商業轉載請註明出處。
原文: http://www.w3cplus.com/css/mindbemding-getting-your-head-round-bem-syntax.html ? w3cplus.com

CSS中的BEM命名

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.