ã¯ããã¾ãã¦ï¼ãã¶ã¤ãã¼ã®ãããã(@kiyoe_furuichi)ã§ãã ãããªããããªQ ã®UIãã¶ã¤ã³ã¨ããã³ãã³ã¼ãã£ã³ã°ãæ å½ãã¦ãã¾ããæè¿æããã¦æº¶ãããã§ããã¹ã¤ã«ãã¹ããï¼
ãã¦ä»åã¯ãçéã§æ¡å¤§æé·ä¸ã®ãããªãè¡ã£ã¦ãããããããCSSè¨è¨ã®ããã®éçºææ³ãã«ã¤ãã¦ã¾ã¨ãã¦ã¿ã¾ããã
ãããããCSSè¨è¨ããèãã
ãããï¼ã¹ã¿ã¤ã«å¹ããªãâ¦!important
ããâ¡ã
身ã®åãã§ãã®ãããªãã¨ã¯èµ·ãã¦ãã¾ãããâ¦ï¼ æå³ããªããã¨ãé »ç¹ã«èµ·ããå ´åãCSSè¨è¨ãã®è¦ç´ããå¿ è¦ããããã¾ããã
ç§ãã¡ã¯æ®æ®µãããµã¼ãã¹ãæé·ããã¦ããã«ããã£ã¦ãããããCSSè¨è¨ãã¨ã¯ãªã«ããèãããã¼ã å
ã§æ¤è¨ããæ¹åããããªã£ã¦ãã¾ãã
ãããªç§ãã¡ãå®è·µãã¦ããéçºææ³ãåãçµãã§ãããã¨ã«ã¤ãã¦ãããã¤ããç´¹ä»ãã¦ããããã¨æãã¾ãã
ãã£ãã
ã¯ããã«ãç§ããããããCSSè¨è¨ããèãã¯ãããã®ã¯ãä»ã®ã¨ã³ã¸ãã¢ããã¨ä¸ç·ã«ããã³ãéçºããããã¨ã«ãªã£ãã¨ãã«èªåã®ä¸ç²æãªããæããã®ããã£ããã§ããã
ããã¾ã§ã²ã¨ãã§ãã¶ã¤ã³/ããã³ãå®è£
ãåãæã£ã¦ããçµé¨ãããªããä»ã®ã¨ã³ã¸ãã¢ãããæ¸ããã³ã¼ããã¬ãã¥ã¼ãããã¾ãç§ãæ¸ããã³ã¼ããã¬ãã¥ã¼ãã¦é ããã¨ãåãã¦ã®ãã¨ã§ãããããã§ããã«èªåã®æ¸ãæ¹ãè² ã®éºç£ãçã¿åºãæ¸ãæ¹ããã¦ããããç¥ã£ã¦ãæãããªã£ãã®ã§æ¹ãã¦CSSã®ãã¨ãåå¼·ãç´ãã¾ããã
ãããæ©ã«CSSã®æ¸ãæ¹ããè¨è¨ã«ã¤ãã¦æ·±ãèå³ãæã¤ããã«ãªããä»ã§ã¯ãµã¼ãã¹ã«ã¨ã£ã¦ããããããããè¨è¨ãã§ããããã¾ããã®è¨è¨ãã¦ã¼ã¶ã¼ä½é¨(éçºè
å«ã)ãã«ã¨ã£ã¦ã©ãè¯ãã®ããèãããCSSããããããã¸ã¨é²åãã¾ããï¼
CSS Architecture
ç§ãã¡ã®èãããããCSSè¨è¨ãã®å®ç¾©ã¯ãè²ã
æ¤è¨ããçµæã1çªç´å¾æã®ããPhilip Waltonãããææ¡ããCSS Architectureããã¼ã¹ã¨ãã¦èãããã¨ã«ãã¾ããã
CSS Architectureã§ã¯ã以ä¸ã®ãããªCSSè¨è¨ãããä¸ã§ç®æãã¹ã4ã¤ã®ã´ã¼ã«ãæ²ãã¦ãã¾ãã ä»ã«ãããããã©ã¯ãã£ã¹ã®æ¹åæ¹æ³ãªã©ãããããè¨è¨ã®ããã®ãã¤ã³ããããã¤ãææ¡ããã¦ãã¾ãã
1.ãäºæ¸¬ãããããã¨ã
追å ãæ´æ°ãããã¹ã¿ã¤ã«ãã¡ããã¨æå¾ éãã«æ¯ãèããã¨ã®ã§ããè¨è¨ã«ãã¾ãããã ãã®ã¹ã¿ã¤ã«ãæå³ãã¦ããªãç®æã«å½±é¿ãä¸ããªãããã«ãããã¨ã
2.ãåå©ç¨ãããããã¨ã
ã¹ã¿ã¤ã«ã¯ããã¿ã³ããã©ã¼ã ãªã©æ©è½ãã¨ã«ç´°ããåé¢ããè¨è¨ã«ãã¾ãããã åå©ç¨æ§ã®ããã³ã¼ããæ¸ããã¨ã§å度åãUIãä½æããå ´åãæ°ãã追å ããæéããªããªãã¾ãã
3.ãä¿å®ãããããã¨ã
è¦ç´ ã追å ã»æ´æ°ãããã¨ã«ãã£ã¦ãæ¢åã®ã¹ã¿ã¤ã«ããªãã¡ã¯ã¿ãªã³ã°ãããããªãã¨ãèµ·ãããªãè¨è¨ã«ãã¾ãããã
4.ãæ¡å¼µãããããã¨ã
ãµã¤ãã®è¦æ¨¡ã大ãããªã£ã¦ããè¤æ°ã®éçºè ãã¡ã³ããã³ã¹ã»ç®¡çããããè¨è¨ã«ãã¾ãããã
ããããã¾ã¨ããã¨ããã¡ã³ãããã«ãªè¨è¨ãããããCSSè¨è¨ã®ã´ã¼ã«ã§ããã¨èãããã¾ãã CSSã¯æ¸ãã®ããããããªåãç ´ç¶»ããããã®ã§éç¨ã»ç®¡çããã£ããã¨èããè¨è¨ã«ãããã¨ã大åã§ããã
ã¡ãªã¿ã«CSS Architectureã¯ã©ããªç°å¢ã§è¨è¨ããã«ããã¦ã(ä»è¨èªã«ããã¦ã)åèã«ãªãã話ãªã®ã§ãèªãã§ããã¨å¹¸ãã«ãªããããããã¾ããï¼
åè :
CSS Architecture
Hiroki Taniããã®æ¥æ¬èªè¨³ CSS Architecture
ç§ãã¡ãå®è·µãã¦ãããCSSè¨è¨ã®éçºææ³ã
ç§ãã¡ã®éçºç°å¢ã§ã¯ãCSSã®è¨è¨ã¬ã¤ãã©ã¤ã³ã¨ãã¦FLOCSS(ãããã¯ã¹)ãã³ã¼ãã£ã³ã°è¦ç´ã«Google HTML/CSS Style Guideãæ¡ç¨ãã¦ãã¾ãã ãã ããããã«å®å ¨ã«æºæ ãã¦ããããã§ã¯ãªããããããã®èãæ¹ããã¼ã¹ã¨ãã¦èªç¤¾ã®ç°å¢ã«åããã®ãåæ¨é¸æãã¦ãã¾ãã
FLOCSSãç¨ããCSSè¨è¨
ãããªã§ã¯ã¤ãå æ¥ãCSSè¨è¨ã®ã¬ã¤ãã©ã¤ã³ã¨ãã¦FLOCSS(ãããã¯ã¹)ãæ¡ç¨ãã¾ããã ç¾å¨ã¯è¦ç´ ã®è¿½å ã»å¤æ´æãªã©ã«ãFLOCSSã«æ²¿ã£ãè¨è¨ã¨ãªããããªãã¡ã¯ã¿ãªã³ã°ãè¡ã£ã¦ãã¾ãã
FLOCSSã¨ã¯ï¼
BEMã®å½åãMCSSãSMACSSã®ã¬ã¤ã¤ã¼è¨è¨ãªã©ã®èãæ¹ãçµã¿åããããCSSè¨è¨ã¬ã¤ãã©ã¤ã³ãã§ããã¡ãã³æ¬ã§æåã§ããï¼ CSS ArchitectureãCSSè¨è¨ã®ç®æãã¹ãã´ã¼ã«ã§ãFLOCSSã¯ç ´ç¶»ããããCSSãã³ã³ãã¼ãã³ã(é¨å)ã¨ãã¦æ±ããã¨ã«ãã£ã¦ãåå©ç¨æ§ãä¿å®æ§ãé«ããCSSã®è¨è¨ã¬ã¤ãã©ã¤ã³ã§ãã
åè :
FLOCSS
CSSè¨è¨ã®æç§æ¸ (ã¡ãã³æ¬)
FLOCSSã使ãã¡ãªãã
å人çã«ä½¿ã£ã¦ã¿ã¦æãããã®ã§ãã以ä¸ã®ã¡ãªãããããããªã¨æãã¾ãï¼
- å¦ç¿ã³ã¹ããä½ããã¨ãã¨ããããã¡ãã³æ¬ãèªãã°å¤§ä¸å¤«ï¼
- æ¥æ¬è£½ãªã®ã§ã»ãã®ã¬ã¤ãã©ã¤ã³ã¨æ¯ã¹ã¦åãçµã¿ãããã£ãã
- OOCSSããã¼ã¹ã«ä½ããã¦ããã®ã§ãã¨ã³ã¸ãã¢ã«ã¨ã£ã¦ãæ§é ã®ç解ããããã
- Objectã¯å
é ã«
.c-*
ã.p-*
ãªã©ã®ãã¬ãã£ãã¯ã¹ãã¤ããã®ã§ç´æçã«æ§é ã®ææ¡ãã§ããã
ã³ã¼ãã£ã³ã°è¦ç´
Google HTML/CSS Style Guideã¨ã¯ï¼
Googleãææ¡ããHTML/CSSã®ãã³ã¼ãã£ã³ã°è¦ç´ãã§ããå½åè¦åãã¤ã³ãã³ããã¹ãã¼ã¹ã®éãæ¹ãªã©ãç´°ããå®ãããã¦ãã¾ãã
åè :
Google HTML/CSS Style Guide
ãGoogle HTML/CSS Style Guideããé©å½ã«å訳ãã¦ã¿ã |
ã³ã¼ãã£ã³ã°è¦ç´ã¯ãGoogle HTML/CSS Style Guideãæ¡ç¨ãã¦ãã¾ãã
ã³ã¼ãã®æ¸ãæ¹ããããããCSSè¨è¨ããç®æããã¨ã«ããã¦èããã¹ãè¦ç´ ã®ã²ã¨ã¤ã¨èãã¦ãã¾ããç¹ã«è¤æ°ã®éçºè
ãã³ã¼ãã管çããå ´åããã³ã¼ãã®èªã¿ãããããèãããã¨ã¯ã¨ã¦ã大åã§ãã
ã¤ã³ãã³ããããããã£ã®è¨è¿°ãªã©ãæã£ã¦ããã ãã§ãå
¨ä½ã®ã³ã¼ããèªãã§ç解ããã¾ã§ã®æ©ãã£ã¦çµæ§å¤ãããã§ãããã
ç¾ç¶åç¬ã§ã®éçºè¡ã£ã¦ããã¨ãã¦ãå°æ¥çã«ã¡ã³ãã¼ãå¢ãããã¨ãè¦è¾¼ã¾ããã®ã§ããã°ãä½ãããã®è¦ç´ãè¨ãã¦ããªã¬ãªã¬ã³ã¼ããã¨ãªããªãããã«æ´å½¢ããã®ããã¿ã¼ãã¨ãããã¾ãï¼
社å ã³ã¼ãã£ã³ã°è¦ç´
ä»ã«ã社å ã§ã®ã³ã¼ãã£ã³ã°è¦ç´ã¨ãã¦ä»¥ä¸ãå®ãã¦ãã¾ãã
ãã¨ãã°ã
- ãµã¤ãºã®åä½ã¯åºæ¬çã«
px
ã§æ¸ãã - classåã§ä½¿ç¨ããåèªã¯ãªãã¹ãçç¥ããªãã
- Role of threeã«ã®ã£ã¨ã£ã¦ãåéãç®æã§ï¼ååãè¦ç´ ã使ç¨ããå ´åã¯ãåå©ç¨ãããã¨ãæ¤è¨ããã(ãªãã¡ã¯ã¿ãªã³ã°)
- jsã§ä½¿ç¨ããclassã¯ã¹ã¿ã¤ã«ãé©ç¨ããclassã¨ã¯å¥ã«ä»ä¸ããã
- jsã§ä½¿ç¨ããclassã¯ããããããå
é ã«
.js-*
ãã¬ãã£ãã¯ã¹ãã¤ããã
ä»ã«ããéçºã®ä¸ã§ããã¯ï¼ã¨ãããã®ãããã°é½åº¦ç¸è«ããã£ã¦ãã«ã¼ã«ãæ´æ°ãã¦ãã¾ãã
ãããããCSSè¨è¨ããçã¿åºã
ãã¦ããããã§ããã§ããããã ä»åãç´¹ä»ããå 容ããã¿ãªããã®ãããããCSSè¨è¨ããèããä¸ã§ããå½¹ã«ãã¦ãã¨å¹¸ãã§ãã
ç§ãã¡ã模索ãããªããæ¥ã ãããããCSSè¨è¨ãã«ã¤ãã¦æ¹åãè¡ã£ã¦ãã¾ãã ç¾æ®µéã§ãããã ï¼ãªçãã¯ã¾ã ããã¾ããããå®è£ ããä¸ã§æèãã¦ãããã¨ãããã¾ãã
ãããææ¥ãã10人ã100人ã®ã¨ã³ã¸ãã¢ãæ¡ç¨ãã¦å ±ã«ãããªã®éçºããããã¨ã«ãªã£ãã¨ããã²ã¨ãã²ã¨ãã容æã«ã³ã¼ããç解ã§ããè¨è¨ã§ãããã¨ããããªãã¨ãããæé·ã®ã¹ãã¼ããæ¢ããªãããã«ãããã³ã渡ããããç°å¢ãç¶æãç¶ãããã¨ããã§ãã
ä¾ãã°ãææ¥ããæ°ããã¨ã³ã¸ãã¢ãã¸ã§ã¤ã³ãã¦ããããããããªã â ããã®è¦ç´ ã¡ãã£ã¨ããããããæ°ãããããã³ã¡ã³ãããã£ãããã«æ¸ãã¦ããããã¿ããã« ãã®å ãã©ããªã£ã¦ããããæ³åãã¦ã³ã¼ããæ¸ããã¨ãã§ããããã«ãªãã¨æãã¾ãã
ã´ã¼ã«ã¨ãã¦ã¯ãã¡ã³ãããã«ãªè¨è¨ããç®æããã¨ã«å¤ããã¯ãªãã§ããããªããããå¿ è¦ãªã®ããæèçã«æ³åãããã¨ã§ããã£ã¨æ®æ®µããããããããæ¸ããããã«ãªããã¨æãã¾ãã
ãã®å°ããªç©ã¿éãããã³ã¼ãã¯ä¸æçãªå®è£
ã®ããã«æ¸ãã®ã§ã¯ãªãããµã¼ãã¹ã®æé·ã®ããã«æ¸ããã¨ãã£ãæ³ããæã¤ãã¨ã¯èªç¶ã¨ãããããCSSè¨è¨ããçã¿åºããã¨ã«ã¤ãªããã®ã§ã¯ãªãã§ããããã
ä»å¾ãå¼ãç¶ããããããCSSè¨è¨ãã«ã¤ãã¦èãã¦ããããã¨æãã¾ãï¼
ã¾ããã¿ãªãããããããã¦èãã¦ã¿ã¾ãããï¼
ãããã«
Connehito.incã§ã¯ããã¦ãã¨ã³ã¸ãã¢ã¨ãã¶ã¤ãã¼ãåéãã¦ã¾ãï¼
çéã§æ¡å¤§æé·ä¸ã®ãµã¼ãã¹ã®CSSè¨è¨ããã£ããã«æ§ç¯ãã¾ãããï¼ï¼
ãã²ã©ãã«ã©ã³ãã§ããï¼ãããããé¡ããã¾ãï¼