ãCSSãè¦åºããå¤ã«æ¹è¡ããªãï¼ã¹ããã®font-sizeæå®ã«vminã使ã£ã¦ã¿ãã
ã¹ããã®font-sizeã®æå®ã§è¯ãããªæå®æ¹æ³ãè¦ã¤ããã®ã§ãç´¹ä»ãããã¾ãã
ç¹ã«è¦åºããªããã®å¤§ããªæåã使ç¨ããå ´é¢ã§æ´»ç¨ã§ãããã§ãã
ã¹ããããããè¦åºãæ¹è¡ãã¡ããåé¡
ã¹ããã®ã³ã¼ãã£ã³ã°ãã¦ãã¨ãè¦åºãããã£ããã³ãã¼ãªã©ã¡ãã£ã¨å¤§ããæåãããã¤ã¹å¹ ã«ãã£ã¦ã¯æ¹è¡ä½ç½®ãæå³ããªãå ´æã«ãªã£ã¦ãã¾ããã¨ã£ã¦ããã¾ãããï¼
ã¹ããããã¤ã¹ã®å¤æ§åã«ä¼´ãçµæ§ç´é¢ããåé¡ãªæ°ããã¾ãã ãã£ããã®ãã¶ã¤ã³ãããã ã¨æ®å¿µã§ãããã
fontãvminã§æå®ããã¨æ¹è¡ããã«æåãµã¤ãºãå°ãããã§ãã
ããã§ç»å ´ããã®ãvminã§ãããããfont-sizeã®æå®ã«ä½¿ããã¨ã§æ¹è¡ããã«è¦åºããã³ã¼ãã£ã³ã°ããäºãã§ãã¾ãã
ç¾èã¯ä¸è¦ã«ããããæ©éãã¢ãè¦ã¦ã¿ã¾ãããã
font-sizeãvminã§æå®ãããã¢
ãã¢ãä½ããã©ã¦ã¶å¹ ã®å¤åã«ãã£ã¦ã©ãå¤ããããGIFã¢ãã¡ã«ãã¦ã¿ã¾ããã
ä¸å´ãvminã§ãã©ã³ããæå®ãããã®ãä¸å´ããã©ã³ããpxæå®ãããã®ã«ãªãã¾ãã
ãã©ã¦ã¶å¹ ã«ãããã¦æåãµã¤ãºãå¯å¤ããã®ã§ãããã ã¨å¹ ãå°ããã®ãã©ã¦ã¶ã§è¦ã¦ãå¤ãªä½ç½®ã§æ¹è¡ãèµ·ããã¾ããã
ãã¡ããæ¬æã¨ã®æåãµã¤ãºã®å ¼ãåããããã®ã§çµ¶å¯¾vminæå®ã®ãè¯ãã¨ã¯è¨ãã¾ãããã(æå®æ°å¤ããã¶ã¤ã³ã«ãã£ã¦ã¯æ¬æã®æåãµã¤ãºããè¦åºãã®æ¹ãå°ãããªã£ããããã)è¦ãã¦ããã¦æã¯ãªãã¨æãã¾ã:)
codeã¯ãããªæãã§ãã(â»å¥ã¦ã¤ã³ãã¦ã§éãã¦ãã©ã¦ã¶å¹ ãå¤ãã¦ã¿ã¦ãã ããã)
See the Pen vmin by Tetsuya Ihata (@tihata) on CodePen.
ç¶ãã¦ãvminã®ç¹æ§ã«ã¤ãã¦è¦ã¦ãã¾ãããã
åä½ãvw/vh/vmin/vmaxã®ããããã®æ§è³ª
vminã¯viewportãåºæºã¨ããç¸å¯¾åä½ã«ãªãã¾ãã
åããããªå±æ§ã®æ°å¤ã«ãvw/vh/vmaxãããã¾ããå¤ã¯ä»¥ä¸ãåºæºã«ãã¦ãã¾ãã
vw
viewport width
ãã¥ã¼ãã¼ãã®å¹
ã«å¯¾ããå²åã§å¤ã決å®
vh
viewport height
ãã¥ã¼ãã¼ãã®é«ãã«å¯¾ããå²åã§å¤ã決å®
vmin
viewport minimum
ãã¥ã¼ãã¼ãã®å¹
ã¨é«ãã®ãã¡ãå¤ãå°ããæ¹ã«å¯¾ããå²åã§å¤ã決å®
vmax
viewport max
ãã¥ã¼ãã¼ãã®å¹
ã¨é«ãã®ãã¡ãå¤ã大ããæ¹ã«å¯¾ããå²åã§å¤ã決å®
vminã®ä½¿ãæ¹
ç»åãªã©ãç»é¢ãã£ã±ãã«åºããã«ã¹ã¯ãªã¼ã³ã®èæ¯ãªã©ã«ãã使ããã¦ããvw/vhã§ãããæåã«æå®ãããã¨ã§ã%ãemãªã©ã¨éãã親è¦ç´ ãåºæºã®ãã©ã³ããµã¤ãºãªã©ããã£ã¨ã°ãã¦ãã¥ã¼ãã¼ããåºæºã«ãµã¤ãºãæå®ãããã¨ãã§ãã¾ãããããã§ããã
ãã©ã¦ã¶å¹ ã ããªãvwã§ãOKã§ãããä»åã¯ç»é¢ã®é«ãã«ãå½±é¿ããvminã§æå®ãå ¥ãã¦ã¿ã¾ãããã¹ãããªã©ã§ã©ããã¦ãç»é¢å ã«æåãå ¥ãããæãªã©ã¯vminã§æå®ããã¨è¯ãããã§ãã
ç»é¢ãã£ã±ãã¯ã100vw/100vhãã§ãã10vwã§æåãæå®ããã¨ããã©ã¦ã¶å¹ ã«10åæåã並ã¶ããã«æå®ã§ãã¾ãã(ãã©ã¦ã¶ããã©ã«ãã®ãã¼ã¸ã³ãããã£ã³ã°ãå ¥ãã¨10å並ã°ãªãäºãããã¾ãã)
対å¿ãã©ã¦ã¶ã¯ä»¥ä¸ã®ãªã³ã¯ãåèã«ãã¦ãã ãããæè¿ã®ã¢ãã³ãã©ã¦ã¶ã¯å¤ã対å¿ãã¦ãã¾ãã
Viewport units(vw, vh, vmin, vmax)ã®åãã©ã¦ã¶ã®ãµãã¼ãç¶æ³
ã¡ãã£ã¨ãã¶ã¤ã³å ¥ãã¦ã¿ãä¾
æå¾ã«ããªãç°¡åã§ããããã¶ã¤ã³(èæ¯ç»å)ãå ¥ãã¦ã¿ãä¾ããç´¹ä»ãã¾ãã
See the Pen vmin2 by Tetsuya Ihata (@tihata) on CodePen.
ä¸å³ã®ããã«codepenãéãã¦ã¦ã¤ã³ãã¦ã®å¹ ãé«ããå¤ãã¦ãæåãç«ã«ãã¶ãäºãªã表示ããã¾ãã
ã¾ã¨ãã¦ããª
以ä¸ã§ã¹ããã®éã®ãã©ã³ãæå®ã§ã¡ãã£ã¨ä¾¿å©ãªvminã®ç´¹ä»ãçµããã¾ãããããã§ãããï¼
以åããããäºããããã¨ãããã縦ã®ã»ããé·ãæã¯ãã®ã¹ã¿ã¤ã«ã横ã®ã»ããé·ãæã¯ãã®ã¹ã¿ã¤ã«ãã¨ããããã«JSã§å ´ååããã¦ãã¨æãã¾ãããCSSã ãã§ç°¡åã«ã§ããã®ã¯æ¬å½ã«ãããããã§ããã
æè¿ã¯ãã£ã¬ã¯ã·ã§ã³ãã¡ã¤ã³ãªã®ã§ãã¶ã¤ã³ãã³ã¼ãã£ã³ã°ã®ç¥èãããããæ ã£ã¦ãã¾ããã¡ãªã®ã§ããªãã¨ããã¦ããããã®ã§ã…æ¥ã ããåå¼·ã
以ä¸ãäºçã§ãã!!
[…] ãCSSãè¦åºããå¤ã«æ¹è¡ããªãï¼ã¹ããã®font-sizeæå®ã«vminã使ã£ã¦ã¿ãã […]
[…] 2. ãCSSãè¦åºããå¤ã«æ¹è¡ããªãï¼ã¹ããã®font-sizeæå®ã«vminã使ã£ã¦ã¿ãã ãã®è¨äºãRTãã […]