CSSã¯èª°ã§ãç°¡åã«èªç±ã«æ¸ããã®ã§ããã好ããªããã«æ¸ãã¦ããã¨ããããå¤æ´ããããéãã¨ãããå´©ãããã¨ãã£ãããã«ããã«ç ´ç¶»ãã¦ãã¾ãã¾ãã
ããã«ãè¤æ°äººã§æ¸ãã¦ããå ´åã¯ãåã ã好ããªããã«æ¸ãã¦èªãã ãã§ãè¦çãªCSSãåºæ¥ä¸ãã£ã¦ãã¾ãã¾ãã
ããã§ããããã®åé¡ã解決ããããã«èããããã®ããCSSè¨è¨ãã§ãã
ä»åã¯è¨äºãé·ããªãéããã®ã§ãCSSè¨è¨ã®æ¦è¦ã®ã¿ã説æããåèã¨ãªãå ¬å¼ããã¥ã¡ã³ãã¸ã®ãªã³ã¯ãè¨è¼ãã¾ããã
CSSè¨è¨ã¨ã¯
CSSè¨è¨ã¯ãCSSãè¨è¿°ããæã®ã«ã¼ã«ã¨ãªããã®ã§ããããã¸ã§ã¯ãæ¯ã«é©ããCSSè¨è¨ãæ¡ç¨ãããã¨ã§ããè¯ãCSSãã«ãããã¨ãã§ãã¾ãã
æè¿ã§ã¯ãå½åè¦åã¯BEMã§ãæ§æã¯SMACCSã®ããã«åCSSè¨è¨ã®æ¦å¿µãåãè¾¼ãã ãªãªã¸ãã«ã®è¦ç´ãã¤ããã¨ãã£ããã¨ãå¤ãããã§ãã
ãè¯ãCSSãã¨ã¯
ãè¯ãCSSãã®å®ç¾©ã¨ãã¦ãããããæãããç¥ããã¦ããã®ã¯ã以ä¸ã®4ã¤ã§ãã
- äºæ¸¬ãããã
- åå©ç¨ãããã
- ä¿å®ãããã
- æ¡å¼µãããã
CSS Architecture
CSS Architectureï¼æ¥æ¬èªè¨³ï¼
ã¾ããCSSè¨è¨ã®åºæ¬ã¨ãªãã¢ã¸ã¥ã¼ã«ãªã©ã«ã¤ãã¦ã¯ãMaintainableCSSãåèã«ãªãã¾ãã
MaintainableCSS
MaintainableCSSï¼æ¥æ¬èªè¨³ï¼
ãã«ãã¯ã©ã¹ã»ã·ã³ã°ã«ã¯ã©ã¹
ï¼ã¤ã®è¦ç´ ã«å¯¾ãã¦ãè¤æ°ã®ã¯ã©ã¹ãæå®ããã®ããã«ãã¯ã©ã¹ãï¼ã¤ãªããï¼ã¤ç¨åº¦ã®ã¯ã©ã¹ãæå®ããã®ãã·ã³ã°ã«ã¯ã©ã¹ã¨å¼ã³ã¾ãã
ä¾ãã°ãBootstrapãã¯ããã¨ããOOCSSã¯ãã«ãã¯ã©ã¹ã§ãBEMã¯ã·ã³ã°ã«ã¯ã©ã¹ãé©ãã¦ããã¨è¨ããã¦ãã¾ãã
ãã ãããããã¯ããã¾ã§å³å¯ãªãã®ã§ã¯ãªããBEMã ãã絶対ã«ã·ã³ã°ã«ã¯ã©ã¹ã«ãã¹ãã¨ããäºã§ã¯ããã¾ããã
OOCSS
OOCSS ã¯ã Object Oriented CSSã®ç¥ã§ããªãã¸ã§ã¯ãæåCSSãªã©ã¨æ¥æ¬èªã§ã¯å¼ã°ãã¾ãã
SMACCSãªã©ã®åºç¤ã¨ãªãèãæ¹ã§ã以ä¸ã®ï¼ã¤ããã¤ã³ãã¨ãªãã¾ãã
- Containerï¼å ¥ãç©ï¼ã¨Contentsï¼ä¸èº«ï¼ã®åé¢
- Structureï¼åºæ¬æ§é ï¼ã¨Skinï¼è¦ãç®ï¼ã®åé¢
Bootstrapã使ã£ããã¨ããã人ã§ããã°ãç解ããããã®ã§ã¯ãªãã§ããããã
ã·ã³ãã«ãªã«ã¼ã«ãªã®ã§æ¡ç¨ãããããåé¢ãBootstrapã®ããã«åUIã«çµ±ä¸ããååãããããã決ãã¦ãããªãã¨ç ´ç¶»ããããã§ãã
BEM
BEMã¨ã¯ãBlockããElementããModifierãã®ç¥ã§ãããè¦ç´ ããã®ï¼ã¤ã«åãã¦èããå³æ ¼ãªå½åè¦åã§ããCSSè¨è¨ã§ä½¿ãå ´åãBEMãå ã«ããMindBEMdingã使ããã¾ãã
ã.Block__Element--Modifierãã¨ããå½åã«ã¼ã«ã«å¾ãã¯ã©ã¹åã決ãã¾ãã
Blockã¯å¸¸ã«ç¬ç«ãã¦ããããã¼ã¸ã®ã©ãã§ãé ç½®ãããã¨ãã§ããä»ã®ãããã¯ãå«ãã ãå«ã¾ããããããã¨ãã§ãã¾ããElementã¯Blockãæ§æããè¦ç´ ã§ãModifierã¯Blockã®ç°ãªãç¶æ ã表ãã¾ãã
ä¾ãã°ã¡ãã¥ã¼ãä¾ã¨ããã¨ã以ä¸ã®ããã«ãªãã¾ãã
- Block ï¼ .menu
- Element ï¼ .menu_item
- Modifier ï¼ .menu__item--current
ã¾ããå½åè¦åã«camelCaseãæ¡ç¨ãããªã©ã«ã¹ã¿ãã¤ãºãã¦å©ç¨ãã¦ãã人ãå¤ãã§ãã
Key concepts | BEM
Key concepts | BEMï¼æ¥æ¬èªè¨³ï¼
MindBEMdingï¼æ¥æ¬èªè¨³ï¼
SMACCS
SMACSSã¯ã Scalable and Modular Architecture for CSS ã®ç¥ã§ãOOCSSãBEMãªã©ãåèã«èæ¡ããã¾ããã
SMACSSã§ã¯ãã¹ã¿ã¤ã«ãBase, Layout, Module, State, Theme ã® ï¼ã¤ã«åãã¦èãã¾ãããã ããThemeã¯ããã¸ã§ã¯ãã«ãã£ã¦ã¯ã使ãããªããã¨ãããã¾ãã
- Base : ããã©ã«ãã®ã¹ã¿ã¤ã«
- Layout : Moduleã®é ç½®ã決ããã¬ã¤ã¢ã¦ã
- Module : åå©ç¨å¯è½ãªãã¼ã
- State : LayoutãModule ç¶æ
- Theme : LayoutãModuleã®å¤è¦³
BEMããç·©ãå½åè¦åã¨ãOOCSSã®ãããªãã«ãã¯ã©ã¹è¨è¨ãç¹å¾´ã§ããå ¬å¼ããã¥ã¡ã³ãã¯ãæ¥æ¬èªã§ã¯æ¬ã§èªããããªãããã§ãã
Scalable and Modular Architecture for CSS
Scalable and Modular Architecture for CSSï¼æ¥æ¬çï¼
MCSS
BEMã¨OOCSSã®åçãåºã«ããCSSè¨è¨ããMCSSï¼Multilayer CSSï¼ã§ãã
CSSã¢ã¸ã¥ã¼ã«ãï¼ã¤ã®ã¬ã¤ã¤ã¼ã«åãã¦èãã¾ãã
- Base : åå©ç¨å¯è½ãªæ¨æºã¹ã¿ã¤ã«ã®ã»ãã
- Project : Baseãå ã«ããããã¸ã§ã¯ãæ¯ã®ã¹ã¿ã¤ã«
- Cosmetic : è²ããµã¤ãºãªã©ãããã«å½±é¿ããã¹ã¿ã¤ã«
BaseãProjectãCosmeticã®ããããã«å±ããã¯ã©ã¹ããè¤æ°æå®ãããã¨ã§UIãä½æãã¾ãã
FLOCSS
OOCSS, SMACSS, BEM, SuitCSS, MCSSãªã©ã®èãæ¹ãåãå ¥ãããã®ã§ãã
å½åè¦åã¯MindBEMdingãæ¡ç¨ããï¼ã¤ã®ã¬ã¤ã¤ã¼ã¨ãObjectã¬ã¤ã¤ã¼ã®åã¬ã¤ã¤ã¼ã§æ§æããã¾ãã
- Foundation : normalize.cssãªã©
- Layout : ã¬ã¤ã¢ã¦ãã®ã¹ã¿ã¤ã«
- Object : ã³ã³ãã¼ãã³ãã®ã¹ã¿ã¤ã«
- Component : åå©ç¨å¯è½ãªã³ã³ãã¼ãã³ã
- Project : ããã¸ã§ã¯ãæ¯ã®ã¹ã¿ã¤ã«
- Utility : clearfixãmarginãªã©ã®å°ããªã¹ã¿ã¤ã«
CSSè¨è¨ã®ããã¨ãåãããããã¨ãã¯ãFLOCSSããã¼ã¹ã«ããã¨è¯ãããããã¾ããã
CSS in JS
React.jsã®æµè¡ã¨å ±ã«ãåºã¾ãã¤ã¤ããã¢ã¤ãã¢ã®ï¼ã¤ã§ããHTMLãJSXã¨ãã¦JavaScriptã§æ±ããããã«ããããã«ãCSSãJavaScriptã®ãªãã¸ã§ã¯ãã«ãã¦æ±ãã¨ããèãã§ããCSSè¨è¨ã¨ã¯ç°ãªãã¾ãããæ°ããCSSã®è¨è¿°æ¹æ³ã¨ãã¦ç´¹ä»ãã¾ãã
React.jsã®éçºè ã®React CSS in JSã«ãã£ã¦ãã®ã¢ã¤ãã¢ãåºã¾ã£ãã¨ããã¦ãã¾ãã
ç¾å¨ãReactã§CSS in JSãå®ç¾ããã©ã¤ãã©ãªã¨ãã¦ã¯ãReactStyleãRadiumãªã©ãããã¾ãã詳ããã¯ãReactã§ä½¿ããã©ã¤ãã©ãªä¸è¦§ãåç §ãã¦ãã ããã
ã¾ããCSS in JSã¨CSS Modulesã«ã¤ãã¦æ¸ãã¦ãããReactã使ã£ãã¢ã¸ã¥ã©ã¼CSS : CSS-in-JSã¨CSS Moduleããåèã«ãªãã¾ãã
Scoped CSS
Scoped CSSèªä½ã¯ãCSSè¨è¨ã§ã¯ãªãHTML5ã§è¿½å ããã scopedå±æ§ã使ã£ãCSSã®è¨è¿°æ¹æ³ã§ãã
åºæ¬ã¨ãªãã®ã¯ãUIãã³ã³ãã¼ãã³ãåãããã®ã³ã³ãã¼ãã³ãå ã§ã®ã¿é©ç¨ãããCSSãè¨è¿°ããã¨ããèãæ¹ã§ãã
Firefox以å¤ã§ã¯ãµãã¼ãããã¦ããããå®éã«ä½¿ããªãã°Pollyfillã使ãããScoped CSSããµãã¼ããã¦ããRiot.jsãªã©ã使ãå¿ è¦ãããã¾ãã
ã¾ã¨ã
ãã®ã»ãã«ãSuit CSSããæè¿ã ã¨Enduring CSSï¼ECSSï¼ãAtomic Designããã¼ã¹ã«ããAPBCSSãªã©ã®CSSè¨è¨ãããã¾ãã
ã¾ããReact.jsãªã©ã®ç»å ´ã«ããJavaScriptã¨CSSãçµã¿åãããæ°ããªã¢ããã¼ããç»å ´ãã¾ããããJavaScriptãç解ããªãã¦ã¯ãªããªãã®ã§æ¡ç¨ããã®ã¯ãããã¼ãã«ãé«ããã§ãã
ã©ã®CSSè¨è¨ãæé©ãã¯ãã¡ã³ãã¼ã¨ãµã¼ãã¹ã®è¦æ¨¡ã«ãã£ã¦ç°ãªãã®ã§ããæ¤è¨ããã»ããè¯ãã§ãããã
ï¼è¿½è¨ï¼APBCSSã®ç´¹ä»ããã¾ã¨ããã«è¿½å ï¼2016/07/11ï¼