正规的彩票

CSS规范BEM CSS和OOCSS的示例代码详解

  发布时间: 2019-06-28 17:09:33   作者: 佚名   正规的彩票要评论
这篇文章主要介绍了CSS规范BEM CSS和OOCSS的示例代码详解,本文给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下

前言

zaixiangmukaifazhong,youyumeigerendedaimaxiguanbutong,bianxiechulaidecssdaimabugoujiegouhua,zhengjieduheyuyihuaqianque。bem cssheoocssdesixiangdajiazairichangbianmazhongyidingyousuoyongdao,zhishimeiyouxitongdelejiehewanquanguifandeshiyong。

BEM(Block, Element, Modifier) CSS 介绍

BEM是一种 前端命名规范正规的彩票 ,顾名思议就是将页面拆分成每一个富有语义的块,块和块可以嵌套,用 连接符 代表各模块之间的关系以及元素状态,生成一种模块化、可复用、高可维护性和结构化的CSS代码。

block

element

modifier(xiushiyu)

duliqieyouyiyideshiti, e.g. header , container , menu , checkbox , etc.

正规的彩票blockdeyibufenqiemeiyoudulideyiyi, header title , menu item , list item , etc.

blockshuoelementsdeyizhongbiaozhi,keyiyongtagaibianqibiaoxianxingshi、xingwei、zhuangtai disabled , checked , fixed

命名规则

正规的彩票tongguoshuangxiahuaxian__lianjiehoudaiblockhuozheelement ,yongshuanglianzifu--lianjiexiushiyu。

zhengguidecaipiaowanquankeyitongguocsshaiyuanchuhtmldaimajiegou

结论

chengxuyuanzuidadekunnanshishenme==>qiming,richangkaifazhongzhengguidecaipiaoyeyudaozijideyangshibeiqitarenfugaile,dabufenyuanyinchuzaimingmingchongtu,bemqiaqiajiejuelezheiyitongdian,zhengguidecaipiaozhixuyaowaicengyangshimingshiyigeyouyiyiqieduliweiyi,tadehoudaijiukeyifangxindeyongcontent,titledenglianjie。(mamazaiyebuyongdanxinzhengguidecaipiaobuhuiqimingle)

youdian: jiegouqingxi,yuyihua。

quedian: ruguohtmljiegouqiantaobijiaoshenhuidaozhileimingbijiaozhang。

OOCSS(Object Oriented CSS) 介绍

oocssbingbushiyizhongyuedingdemingmingguifan,shiyizhongmianxiangduixiangdesixiang,mianxiangduixiangzhengguidecaipiaobingbumosheng,jiangmokuaichouxiangchengduixiang,qihexinjiushiyongzuijiandandefangshibianxiezuizhengjie,zuiyujingdecssdaima,congershidaimagengjuzhongyongxing,keweihuxinghekekuozhanxing。

hexinsixiang:

  • 减少对 HTML 结构的依赖
  • 增加 CSS class 重用

原则

减少对 HTML 结构的依赖

一般的导航栏写法,如果要对那些 <a> 标签定义样式,CSS 的写法可能写成 .nav__main ul li a {} ,这种写法先不管效能上的问题,可以看出来过度地依赖元素标签的结构,有可能之后 HTML 结构改变,这个 CSS 就必须跟著重构,造成维护上多余的成本,OOCSS提倡给a标签加上class .nav__main__item

增加 CSS class 重复性的使用

zaishiyongoocsszhiqianzhengguidecaipiaoxieyigeyangshikenengshizheiyangde,zheiyangxiedebiduanshisuichukejiandezhongfudaima,weihuqilaitebiemafan。

正规的彩票zhengguidecaipiaokeyitongguofenxichouxiangchutamengongyoudeyangshi,yincitichuleyigekezhongyongdezitiyangshi。

jielun

oocsszuizhongyaodeshicongxiangmudeyemianzhongfenxichouxiangchu“duixiang”zujian,bingjizheixieduixiangchuangjiancssguizejinxingwanshan,ranhouwulunshizaixiangmuzhongxinjianyemianhaishizaimokuaizhongtianjiayuansu,zhixuzhongxieshaoliangdeshenzhibuxierenheyangshi。

正规的彩票bemheoocssdejiehe

正规的彩票zhengguidecaipiaokaifayigexianshiwupinzhongliangzujian,zhengguidecaipiaopingchangxiededaimakenengshizheiyangde。

kanqilaimeishenmemaobing,danshiwulunshikeweihuxing,jianjiedudoufeichangdecha。ruguozhengguidecaipiaoshiyongbemheoccsszhengguidecaipiaokeyijiangzhengguidecaipiaodedaimabianchengzheiyang。

xiangduiyuqianzhongfangan,mingmingbijiaorongzhang,danshibaozhengcssleimingbuhuizhongfude,yangshibuyilaihtmljiegou,fuyongclass,zhengshibemheoocssdehexinsixiang。

总结

正规的彩票bemshiyizhongmingmingguifan,oocssshicssdeshejisixiang,qishibemyeyongdaoleoocssdesixiang。

css daimadeshuliangyufapangda,kaifatuanduideguimoyexiangyingkuoda。zai css kaifatuanduizhongxuyaoyigetongyihegudingde css daimazuzhiheguanliguifan,ruoyoubuzuzhichuhuanyingdajiabuchong。

daocizheipianguanyucssguifanbem cssheoocssdeshilidaimaxiangjiedewenzhangjiujieshaodaozheile,gengduoxiangguancssguifanbem cssheoocssneirongqingsousuojiaobenzhijiayiqiandewenzhanghuojixuliulanxiamiandezhengguidecaipiaoxiangguandewenzhang,xiwangdajiayihouduoduozhichijiaobenzhijia!

正规的彩票相关的文章

  • 深入解读CSS的OOCSS和SMACSS以及BEM

    这篇文章主要介绍了CSS的OOCSS和SMACSS以及BEM,这三种CSS编程方式也是目前前端设计开发中的主流,需要的朋友可以参考下
    2014-07-28

最新评论

正规的彩票_正规彩票平台app下载[首页最快线路√] 彩票官网_彩票官网app|网站首页 彩票平台_彩票平台快三-[平台最快线路√] 彩票app下载_彩票app下载官网下载快三_官方入口 彩票平台_彩票平台app-专注彩票门户 彩票官网_彩票官网app下载网址-HOME 彩票平台_彩票平台登录-老品牌最信誉 彩票app_彩票app客户端下载>> 首页 彩票平台_彩票平台免费送彩金18-点击进入>! 彩票平台_彩票平台官网〖2020购彩首选〗 彩票app_彩票app彩票投注平台-Welcome