CSSè¨è¨ã®æç§æ¸ãã¾ã¨ãã¦ã¿ã
CSSè¨è¨ã®æç§æ¸ãèªãã§ãä»å¾æèãã¦ããã¹ãé
ç®ã大éæã«ã¾ã¨ãã¦ã¿ã¾ããã
ãã£ã¨ç¥ãããã¨ããæ¹ã¯æ¬ã®è³¼å
¥ããªã¹ã¹ã¡ãã¾ãã
ããããCSSã®è¨è¨ã¨ã¯
-
äºæ¸¬ãããã
æå¾ éãã«æ¯ãèãã追å ããã«ã¼ã«ãä»ã®ã«ã¼ã«ã«å½±é¿ãä¸ããªãã -
åå©ç¨ãããã
æ½è±¡çã§åé¢ãããå度ééããåãUIã«å¯¾ãã¦ãå度æ¸ãç´ãå¿ è¦ããªãã ä¿å®ãããã
æ°ããã«ã¼ã«ã追å ã»æ´æ°ããã¨ãã«æ¢åã®ã«ã¼ã«ã®ãªãã¡ã¯ã¿ãªã³ã°ãå¿ è¦ã¨ããªããæ¡å¼µãããã
èªåã¨èªå以å¤ã®äººã«ãã¡ã³ããã³ã¹ã»ç®¡çãããããã
ç ´ç¶»ããããCSSã®ç¹å¾´
- HTMLæ§é ã«ä¾åãã¦ãã
- ã¹ã¿ã¤ã«ãåãæ¶ãã¦ãã
- 絶対å¤ãå¤æ§ããã¦ãã
ã³ã³ãã¼ãã³ãè¨è¨ã«ã¤ãã¦ã®æ¦è¦ãè¨è¼ããã¦ãããã¨ã¦ãåãããããä¸å¯§ã«ã¾ã¨ã¾ã£ã¦ãã¾ãããOOCSSã¨ãSMACSSã¨ãBEMã¨ãèãããã¨ãããã©ãããã¨ããæ¹ã¯å¿
è¦ã
ã³ã³ãã¼ãã³ãè¨è¨ã®æ¦è¦ã«ã¤ãã¦
OOCSS
æ§é ã¨è¦ãç®ã®åé¢
ã³ã³ãã¼ãã³ãã®åºæ¬æ§é ã¨ãå ·ä½çãªã«ã¼ã«ã»æ©è½ãåé¢ãããã³ã³ããã¼ã¨ã³ã³ãã³ããåé¢
å ´æã«ä¾åããªãã»ã¬ã¯ã¿ãæ¸ãã
SMACSS
ä¸è¨ã®ããã«ã«ãã´ã©ã¤ãºãã¦è¨è¨ããã
Base
ãã©ã¦ã¶ãããã³ãã®ããã¸ã§ã¯ãã«ç½®ãããåè¦ç´ ã®ããã©ã«ãã®ã¹ã¿ã¤ã«ãå®ç¾©ãhtmlãbodyã«å®ç¾©ããã§ããããå ¨ä½ã®èæ¯ããã©ã³ãããªã³ã¯è²ã¨ãã£ããã®ãå«ãããªãã¹ãæ¸ãæãã¯ããããªããããwidthãmarginãpaddingçã¯è¨è¼ããªããLayout
IDãç¨ãã¦å®ç¾©ããããããªãããã¼ãããã¿ã¼ããµã¤ããã¼ãã³ã³ãã³ãã¨ãªã¢ãæ§æã®å¤§æ ãã»ã¯ã·ã§ã³ãä½ãè¦ç´ ã¸ã®ã«ã¼ã«ããããã¯IDã§è©³ç´°åº¦ãããã¦ãOKãModule
ãã¿ã³ãè¦åºãããªã³ã¯ãªã©ãlayoutãé¤ãããããåå©ç¨å¯è½ãªãªãã¸ã§ã¯ãã該å½ãState
JSã®å¶å¾¡ã§åãæ¿ãããããªç¶æ ã表ããã®ãã¡ãã£ã¢ã¯ã¨ãªã§ã³ã³ãã¼ãã³ããå¶å¾¡ãããã®ã該å½ã.is-*ã¨ããæ¥é è¾ãã¤ããã®ãæ¨å¥¨ãStateã§ã¯!importantã使ãã®ã¯è¨±å®¹ãTheme
ãã¼ããåãæ¿ãããããªãã®ã.them-*ã¨ããæ¥é è¾ãã¤ããã®ãæ¨å¥¨ã
BEM
ãªãã¸ã§ã¯ã/ã³ã³ãã¼ãã³ãã3ã¤ã«åãã¦åé¡ããã
ä¾: <div class="alert alert_waring> <h1 class="alert__title">ãã¹ã¯ã¼ããéãã¾ãã</h1> <p class="alert__body">ååº¦å ¥åãã¦ãã ããã</p> </div>
Block
ä¾ã®.alertã該å½ãElementãModifierã¯ãããåºç¹ã«å½åãã¦ãããElement
Blockãæ§æããè¦ç´ ãalertã¨ããBlockã«å¯¾ããElementã¨ãããã¨ã§ã¢ã³ã¹ã³ã2ã¤ä»ããå½åã«ããã.alert__titleã.alert__bodyã該å½ãModifier
Blockã¾ãã¯Elementã®ããªã¨ã¼ã·ã§ã³éãã®è¦ç´ ãSMACSSã®Stateã®ãããªãã®ã該å½ãä¸è¨ã§ã¯ã.alert_waringã該å½ããModifierã¯ã¢ã³ã¹ã³1ã¤ã¤ãã¦å½åããã
ã³ã³ãã¼ãã³ãè¨è¨æã®æ³¨æç¹
æé©åãç¦ããªã
Rule of threeã3åç¹°ãè¿ãããã®ã¯ããã¿ã¼ã³ã¨ãã¦æç«ãããç¡é§ã«è©³ç´°åº¦ããããªã
h2.title {...} â .title {...}
ã»ã¬ã¯ã¿ã¨ãã¦ã¯è¦ç´ ãçç¥ãã¦ãåé¡ç¡ãããh2ã§ãªãã¨ãh1ãh3ã§ã使ç¨ã§ããããã«ããã¹ããæ§é ã¨ãã責任ã¨è¦ãç®ã¨ãã責任ã®åé¢ ããã¹ãã«ã©ã¼ããµã¤ãºããã¼ãã¼ãèæ¯ã¨ãã£ãè¦ãç®ã¨positionãfloatãªã©ã¨ãã£ãæ§é ãä¸ç·ã®ã«ã¼ã«ã»ããã«ããªããã¨ã
éæ¾/ééã®åå
ã³ã³ãã¼ãã³ãã®ãã¼ã¹ã¨ãªãã«ã¼ã«ã¨ããã®ã¯ãä¸æ¸ãã»æ¡å¼µãããã(éæ¾ç) ã§ããéãå¤æ´ãããã¹ãã§ã¯ãªã(ééç)åå©ç¨ããã¹ã¦ã§ã¯ãªã ã³ã³ãã¼ãã³ãã«ãããåå©ç¨æ§ã¨ããã®ã¯ãã³ã³ãã¼ãã³ãã®åä½ã§åå©ç¨ããã¨ãããã¨ã éå°ã«åå©ç¨ãããã¨ãæèãã¦ãç°ãªãã³ã³ãã¼ãã³ããæ··ããªãããã«ã
ããã«è¨è¨ããªãã¡ã¯ã¿ãªã³ã°ãå¦ã³ãã人ã«ã¯ä¸è¨ããªã¹ã¹ã¡ãããã