ååï¼【解説】はてなブログのHTML/CSSの構造を解析する(2) - daisukeの技術ブログï¼ãåã
åï¼【解説】はてなブログのHTML/CSSの構造を解析する - daisuke20240310のブログï¼ã¨ãã¯ã¦ãªããã°ã®HTML/CSSã®æ§é ã調ã¹ã¾ããã
ããããã¯ãå®éã«ãã¯ã¦ãªããã°ã®ãã¼ããMinimalismããã«ã¹ã¿ãã¤ãºãã¦ããã¾ãã
ãã®ããã°ã§ã¯ããMinimalism ããã¼ãã使ç¨ãã¦ãã¾ããããªãã¹ããã©ã®ãã¼ãã®å ´åã§ã対å¿ãã§ããæ¹æ³ã§èª¬æãã¦ããã¾ãã
ã¾ãã¯ãã³ã¼ããããã¯ã®è¡éãåºãããã®ã§ããã®èª¿æ´æ¹æ³ã«ã¤ãã¦æ¸ãã¦ããã¾ãã
â»2024/3/30追è¨ï¼å
¨ä½ã®èæ¯è²ãç½ãªã®ã§ãã³ã¼ããããã¯ã¯å°ãéãèæ¯è²ãè¨å®ãã¾ãã
åèæç®
åèãµã¤ã
help.hatenablog.com
ã¯ããã«
ããã°ã«ã¹ã¿ãã¤ãºã®ä¸è¦§ã§ããè¯ãã£ããåèã«ãã¦ãã ããã
ããã°ã«ã¹ã¿ãã¤ãºã®ã¾ã¨ã
æåã«ãä»åã®ã¾ã¨ãã¨ãã¦ãå¤è¦³ã®ããã©ã¼ã¢ãã¿ã¼ã¨ããã¶ã¤ã³CSSã®æ«å°¾ã«ã³ããããã°ããã³ã¼ããè²¼ã£ã¦ããã¾ãã
å¤æ´å
å¤æ´å¾
ãã¶ã¤ã³CSSã«è¿½è¨ããå
容
.entry-content pre {
line-height: 23px;
background: #fdfdfd;
}
äºåæºå
ãã¹ãç¨ã®ããã°ãéè¨ãã
ã¯ã¦ãªããã°ã§ã¯ãç¡æã¢ã«ã¦ã³ãã®å ´åã3åã¾ã§ããã°ãéè¨ãããã¨ãã§ãã¾ãï¼ææã¢ã«ã¦ã³ãã¯10åã¾ã§éè¨ã§ããããã§ãï¼ã
ããã¶ã¤ã³ãã¼ãå¶ä½ã®æå¼ããã«ãæ¸ããã¦ãããã«ãä½æãå¤æ´ãããã¼ãã確èªããããã®ãã¹ãç¨ã®ããã°ãéè¨ãã¾ãã
æ°ããããã°ãéè¨ããã«ã¯ãã¯ã¦ãªããã°ã®ç®¡çç»é¢ããããããã·ã¥ãã¼ãããéãããæ°ããããã°ãä½æããæ¼ãã¦ãå¸æã®URLãé¸ã¶ã¨ãããã°ãéè¨ã§ãã¾ãã
ãµã³ãã«ã¨ã³ããªã¼ãæ稿ãã
åèãµã¤ãã®ããã¶ã¤ã³ãã¼ãå¶ä½ã®æå¼ããã«ã¯ããã¶ã¤ã³ã確èªããããã«ãã¯ã¦ãªããã°ã®è¨äºã«å¿
è¦ãªè¦ç´ ãã¾ã¨ããããµã³ãã«ã¨ã³ããªã¼ããç¨æãã¦ããã¦ãã¾ãã
ãã®ããµã³ãã«ã¨ã³ããªã¼ããããã¹ãç¨ã®ããã°ã«æ稿ãã¦ããã¾ãã
ãªãããã®ããµã³ãã«ã¨ã³ããªã¼ãã¯ãMarkdownè¨æ³ã§ç¨æããã¦ããã®ã§ãç·¨éã¢ã¼ããMarkdownè¨æ³ã«è¨å®ãã¦ãããè²¼ãä»ãã¦ãã ããã
æ稿ããããµã³ãã«ã¨ã³ããªã¼ãã表示ãã¦ããå³ã¯ãªãã¯âãã¼ã¸ã®ã½ã¼ã¹ã表示ããè¡ãã表示ãããHTMLã®ã½ã¼ã¹ã³ã¼ãããå
¨ã¦é¸æãã¦ã³ãã¼ãããã¹ããã¡ã¤ã«ã«ä¿åãã¦ããã¾ãã
ãMinimalismããã¼ãã®CSSãå
¥æãã
ã¯ã¦ãªããã°ã®ããã°ã®ç®¡çãããã ãã¶ã¤ã³â ã«ã¹ã¿ãã¤ãºãã¯ãªãã¯â{} ãã¶ã¤ã³CSSããã@import "http...";
ã¨ãªã£ã¦ããã®ã§ãhttp...
ã®é¨åãã³ãã¼ãã¦ããã©ã¦ã¶ã®ã¢ãã¬ã¹ãã¼ã«è²¼ãä»ãã¾ãã
ããã¨ããMinimalismããã¼ãã®CSSã表示ãããã®ã§ãå
¨ã¦é¸æãã¦ã³ãã¼ãããã¹ããã¡ã¤ã«ã«ä¿åãã¾ãããã¬ã¤ã«æ¸ããã¦ããã®ã§ãä»åã¯æ´å½¢ã¯å¿
è¦ããã¾ããã
ãMinimalismããã¼ããã«ã¹ã¿ãã¤ãºãã
ã¾ããä¸è¨ã§éè¨ãããã¹ãç¨ã®ããã°ã®æ稿ããããµã³ãã«ã¨ã³ããªã¼ããéããChromeã®ãããããã¼ãã¼ã«ï¼F12ãã¼ or ã¡ãã¥ã¼âãã®ä»ã®ãã¼ã«âãããããã¼ãã¼ã«ï¼ãéãã¾ãã
ããã¦ã以ä¸ã®å³ã®ããã«ããããããã¼ãã¼ã«ã®ããã¼ã¸å
ã®è¦ç´ ãé¸æãã¦æ¤æ»ããã¯ãªãã¯ãã¦ããããMinimalismããã¼ãã®æ°ã«ãªã£ãå ´æãã¯ãªãã¯ãã¾ãã
ããã§å¤æ´ããã¨ãããæããã«ãªã£ãã®ã§ããã¨ã¯ã好ã¿ã®è¦ãç®ã«ãªãããã«ããããããã¼ãã¼ã«ã§å¤æ´ãã¦ããã¾ãï¼å
·ä½çãªããæ¹ã¯å¾è¿°ï¼ã
å¤æ´å
容ã®CSSã決ã¾ã£ãããã¯ã¦ãªããã°ã®ããã°ã®ç®¡çãããã ãã¶ã¤ã³â ã«ã¹ã¿ãã¤ãºãã¯ãªãã¯â{} ãã¶ã¤ã³CSSãã§ãæ«å°¾ã«å¤æ´å
容ãè²¼ãä»ããã°OKã§ãã
ã§ã¯ãé çªã«ã«ã¹ã¿ãã¤ãºããå
容ã«ã¤ãã¦é çªã«æ¸ãã¦ããã¾ãã
ã³ã¼ããããã¯ã®è¡éãåºãããã®ã§èª¿æ´ãã
ä¸è¨ã®å³ã«ããããã«ããMinimalismããã¼ãã®ã³ã¼ããããã¯ã¯è¡éãåºãããã®ã§ãå¤æ´ãã¾ãã
ä¸è¨ã®æé ã§ããããããã¼ãã¼ã«ã§ãã³ã¼ããããã¯ã®HTMLï¼preã¿ã°ï¼ã¨CSSãç¹å®ãã¾ããCSSã¯ãä¸ããé çªã«é©ç¨ãããã®ã§ãæªããããªå
容ãé ã«è¦ã¦ããã¾ãã
ããã¨ã.entry-content
ã®line-height: 34px;
ã¨ããã®ãè¦ã¤ããã¾ãããã®å·¦ã«ãããã§ãã¯ããã¯ã¹ãON/OFFãã¦ãã³ã¼ããããã¯ãå¤åãããã確èªãã¾ãã
1ã¤ç®ã®å³ã¯ããã§ãã¯ããã¯ã¹ãONã§line-height: 34px;
ãæå¹ãªç¶æ
ã§ããã2ã¤ç®ã®å³ã¯ããã§ãã¯ããã¯ã¹ãOFFã§line-height: 34px;
ãç¡å¹ãªç¶æ
ã§ãã
ãã®ãã¨ããã.entry-content
ã®line-height: 34px;
ãã³ã¼ããããã¯ã®è¡éãåºããã¦ããåå ã§ãããã¨ãåããã¾ãã
ã§ã¯ããã¨ã¯æ°ã«å
¥ã£ãæãã«å¤æ´ããã°ããã§ãããå¤æ´æ¹æ³ã¯ããèããªããã°ãªãã¾ããã
.entry-content
ã¨ããã¯ã©ã¹ã¯ãè¨äºã®æ¬æå
¨ä½ã®å®ç¾©ã«ãªã£ã¦ãããline-height: 34px;
ãåé¤ãã¦ãã¾ãã¨ãè¨äºã®æ¬æå
¨ä½ã®è¡éãçããªã£ã¦ãã¾ãã¾ãã
å®éã«ããã§ãã¯ããã¯ã¹ãOFFã«ããç¶æ
ã§ãã³ã¼ããããã¯ä»¥å¤ã®å ´æãè¦ãã¨ãè¡éãçããªã£ã¦ãã¾ã£ã¦ãããã¨ãåããã¾ãã
ä»ã®æ¹ãä½ã£ãã½ã¼ã¹ã³ã¼ããå¤æ´ããå ´åãå
¨ä½ãææ¡ãã¦ãªãããããªãã¹ãå½±é¿ãåºãªããããªå¤æ´ã«ããã¹ãã§ãããã
ã§ã¯ãå
·ä½çã«ã©ãããã°ãããã¨ããã¨ããMinimalismããã¼ãã®CSSãä¿åãããã¡ã¤ã«ãéããentry-content
ã§æ¤ç´¢ãã¾ãã
ãããè¦ãã¨ãä»åã¯ãpreã¿ã°ã§ãcodeã¯ã©ã¹ãªã®ã§ã.entry-content pre
ã.entry-content pre > code
ã.entry-content code
ã¨ãã3ã¤ãè¦ã¤ããã¾ãããæå¾ã®ã¯ããããä»ãã¦ãªãã®ã§ãcodeã¯ã©ã¹ã§ã¯ãªãcodeã¿ã°ã§ãããçãä¸ããpreã¿ã°å
ã®codeã¿ã°ã¨ããæå³ãªã®ã§ãä»åã®å¯¾è±¡ã§ã¯ãªãã§ããããã£ã¦ãæåã®.entry-content pre
ãä¸çªå½±é¿ãä¸ãã«ããã®ã§ããããå¤æ´ãã¾ãã
å
·ä½çã«ã¯ãline-height: 34px;
ãè¯ããªãã£ãã®ã§ãåãããããã£ã§ãline-height: 23px;
ã¨ä¸æ¸ããã¦ã¿ã¾ããã©ã®æ°å¤ããããã¯ã以ä¸ã®å³ã®ããã«ããããããã¼ãã¼ã«ã§ããããã試ãã¦ãããå¤ãé¸ã¹ã°OKã§ãã
ãããããã¼ãã¼ã«ã§è¡ã£ãå¤æ´ã¯ãä¸æçãªãã®ã§ããããªãã¼ãããã¨ãå
ã®ç¶æ
ã«æ»ãã¾ããããã°ã«åæ ããã¨ãã¯ã以ä¸ã®ããã«ãã¶ã¤ã³CSSã«è¿½è¨ããå¿
è¦ãããã¾ãã
以ä¸ã¯ã.entry-content pre
ã®ããããã£ã®å¤æ´åã¨ããã¶ã¤ã³CSSã«è¿½è¨ããå
容ã§ãã
å¤æ´å
.entry-content pre {
border: 1px solid #ECEEF1;
margin: 0 0 10px;
padding: 20px;
white-space: pre;
}
ãã¶ã¤ã³CSSã«è¿½è¨ããå
容
.entry-content pre {
line-height: 23px;
}
èæ¯è²ã®æå®ã追å ãã
ç¾å¨ã®ããã°å
¨ä½ã®èæ¯è²ãç½ãªã®ã§ãã³ã¼ããããã¯ã¯å°ãéãè²ã«å¤ãããã¨æãã¾ãã
ãã¶ã¤ã³CSSã«è¿½è¨ããå
容
.entry-content pre {
line-height: 23px;
background: #fdfdfd;
}
ãããã«
ãã¨ã¯ãã¯ã¦ãªããã°ã®ç®¡çç»é¢ãããã ãã¶ã¤ã³â ã«ã¹ã¿ãã¤ãºãã¯ãªãã¯â{} ãã¶ã¤ã³CSSãã§ãæ«å°¾ã«å¤æ´å¾ã®å
容ãè²¼ãä»ãã¦ãå¤æ´ãä¿åããã°ãããã°ã«åæ ããã¾ãã
ä»åã¯ä»¥ä¸ã§ãï¼