ðãŠã§ããµã€ãã®äœæð
ðãŠã§ããµã€ãã®äœæ
HTMLãšCSSã®å®è·µïŒ
æ°ãããããã¯ã«ã€ããŠãå®è·µã亀ããªãã
ã³ãŒãã£ã³ã°ã«å©çšããããšã§å¹ççã«åŠç¿ã§ããðð»ââïž
Webãµã€ãã®å®è·µ
ð±html5ãªã»ããã·ãŒã
CSSããªã»ããããããã®CSSãã¡ã€ã«
ãã©ãŠã¶ãããã©ã«ãã®CSSãæã£ãŠããå Žåãããã®ã§
ããããªã»ããããã¬ã€ã¢ãŠããžã®åœ±é¿ãæžããããã®ãã®ã
äºæããªããã©ãã«ãæžããããšãã§ããïŒ
CSSããªã»ããããããã®ãã¡ã€ã«ã¯èªåã§æžããŠãè¯ããå ¬éãããŠããå®çžŸã®ãããã®ã䜿ã£ãŠãâ
CSSãã©ã«ãå
ã«å
¥ãã
â ïžCSSãã©ã«ãããäžã«é
眮
<link rel="stylesheet" href="css/html5reset-1.6.1.css">
<link rel="stylesheet" href="css/base.css">
CSSã¯ååäžããäžã«åãã£ãŠè§£éãããã®ã§ã
èªåã§èšè¿°ããã¹ã¿ã€ã«ã®åæ ãæ¶ããŠããŸãã¬ããé åºãéèŠïŒ
ð±HTMLã®ããŒã¯ã¢ãã
-
ããŒã¯ã¢ãã
HTMLã¿ã°ã䜿ã£ãŠãæç« ãæ§é åããäœæ¥ã®ããš
ãã©ãŠã¶ããããèªèããããšã§ãèŠåºãã»ãªã¹ãã»ãªã³ã¯ãªã©ãç»é¢äžã«ãããããã衚瀺ããã -
ã³ãŒãã£ã³ã°
HTMLã ãã§ãªããJavaScriptãPHPãPythonãRubyãªã©ã®ããŸããŸãªããã°ã©ãã³ã°èšèªãçšããŠããœãŒã¹ã³ãŒãå šäœãèšè¿°ããŠããäœæ¥ã®ããš
ã€ãŸãããœãŒã¹ã³ãŒããèšè¿°ããã³ãŒãã£ã³ã°ã®äžã«ããŒã¯ã¢ãããè¡ãäœæ¥ãããããšããèãæ¹ã«ãªã
Ï(
ããŒãžããšã«éãã¹ã¿ã€ã«ãåœãŠããæã«idãæ¯ã£ãŠãããšäŸ¿å©
idãã¯ã©ã¹ãã€ããã¿ã€ãã³ã°ã¯ç¹ã«æ±ºãŸãã¯ãªããã
è¬åž«ã®æ¹ã¯HTMLãèšè¿°ãã段éã§ããçšåºŠä»ããŠããŸã
CSSãèšè¿°ãã段éã§äžè¶³ããå Žåã¯ä»ã足ããšãã£ãããšãå€ããããïŒ
ð±ãããŒç»åã®èšå®
å®åã§ã¯éçºãå§ããŠãç»åãªã©ã®çŽ æãåºæ¥äžãã£ãŠããªãããšãããããããã
ä»ã®äœæ¥ãé²ããããããã«ãããŒã®ç»åãå
¥ããŠã
çŽ æãåºæ¥äžããã°å·®ãæ¿ããã°OKïŒïŒ
ãããŒç»åãæ¿å ¥ã§ãããµã€ãã®äžã€ð
å ¥åäŸïŒ
暪x瞊CSSã«ããã¹ã¿ã€ã«ã®èšå®
Ï(
header nav ul li a:hover,
header nav ul li a:active,
header nav ul li.current a {
color: #8c6239;
}
-
a:link { color: blue; } /* æªèšªåãªã³ã¯ */
-
a:visited { color: purple; } /* 蚪åæžã¿ãªã³ã¯ */
-
a:hover { background: yellow; } /* ãããŒæ */
-
a:active { color: red; } /* ã¢ã¯ãã£ããªãªã³ã¯ */
-
p:active { background: #eee; } /* ã¢ã¯ãã£ããªæ®µèœ */
Rem
remïŒã¬ã ïŒã¯ãroot emãã®ç¥ã§ãååã®ãšãããæäžäœéå±€ã®ãemïŒãšã ïŒãããæå³ãã
ïŒemã¯æŽ»åã§çšããããŠãã倧æåãMãã®å€§ãããåºæºã«ïŒæååã®å€§ãããè¡šãåäœïŒ
ã¡ãªãã
- 芪èŠçŽ ã®æå®ã®åœ±é¿ãåããã%ãããemãã«æ¯ã¹ãŠãåã ã®èŠçŽ ã®æåãµã€ãºã®èšå®ããããã
- HTMLèŠçŽ ã®æåãµã€ãºã調æŽããããšã§ãµã€ãå šäœã®æåãµã€ãºå€æŽã«ã察å¿ãããã
#info dd {
width: calc(100% - 7em);
}
calc() ã¯CSSã®é¢æ°ã§ãCSSã®ããããã£å€ãæå®ããéã«èšç®ãè¡ãããšãã§ãããã®
<length>ã<frequency>ã<angle>ã<time>ã<percentage>ã<number>ã<integer>
ãå©çšã§ããå Žæãªãã°äœ¿çšã§ãã
footer ul li a:hover,
footer ul li a:active {
opacity: 0.7;
}
opacity ã¯CSSã®ããããã£ã§ãèŠçŽ ã®äžéæ床ãèšå®ã§ãã
äžéæ床ã¯èŠçŽ ã®è£ã«ããã³ã³ãã³ããé ãã床åãã§ãããéæ床ã®é
ð±ã¬ã¹ãã³ã·ã察å¿
端æ«ã®ãµã€ãºã«ãã£ãŠèŠããã衚瀺ã«åãæ¿ã
ã¹ããŒããã©ã³ãªã©æšªå¹
ã®å°ãã端æ«ã§èŠãå Žåã«çž®å°ããèŠã¥ãã
viewport
viewportãšã¯ã PCãã¢ãã€ã«ïŒã¹ãããã¿ãã¬ããïŒãšãã£ãããã€ã¹ããšã«
ã³ã³ãã³ãã®è¡šç€ºé åãèšå®ããããã®HTMLå±æ§å€ïŒmetaèŠçŽ ã®nameå±æ§ã®å±æ§å€ïŒã®ããš
çŽèš³ãããšã衚瀺é åããæå³ããèªã¿æ¹ã¯ããã¥ãŒããŒãã
metaèŠçŽ ã®viewportã§æå®ããããšã§ãPCã»ã¢ãã€ã«ãªã©ã®è¡šç€ºé åãæå®ã§ãã
<head>
<meta name=âviewportâ content=âwidth=device-width,initial-scale=1â³>
</head>
Ï(
Googleã¯ãçŸæç¹ã§ãã®èšè¿°ãæšå¥šããŠãã
衚瀺é åã®å¹
ãæå®ããæ¹æ³ãããããçŸåšã¯ç«¯æ«ç»é¢ã®å¹
ã«åãããããšãæšå¥š
ãwidth=device-widthããèšè¿°ããããšã§ã衚瀺é åã®å¹
ããPCãã¹ãããªã©ã®ç«¯æ«ç»é¢ã®å¹
ã«åããããã
ãŸãããinitial-scale=1ãã¯åæã®ãºãŒã åçãè¡šãã1ã«èšå®ããããšã§ãåãã«è¡šç€ºãããæã®éåæããªãã
ð±viewportã§èšå®å¯èœãªèŠçŽ
- widthïŒæšªå¹ ïŒ
- heightïŒçžŠå¹ ïŒ
- initial-scale ïŒåæåçïŒ
- maximum-scaleïŒæ倧åçïŒãšminimum-scaleïŒæå°åçïŒ
- user-scalable ïŒãºãŒã æäœã®å¯åŠïŒ
åèãµã€ã
ð±ã¡ãã£ã¢ã¯ãšãªãŒã®äœ¿çš
ã¡ãã£ã¢ã¯ãšãªãŒã¯ãäžè¬çãªç«¯æ«ã®çš®é¡ (ããªã³ã¿ãšç»é¢ãªã©)ãç¹å®ã®ç¹æ§ (ç»é¢ã®è§£å床ããã©ãŠã¶ãŒã®ãã¥ãŒããŒãã®å¹ ãªã©) ã«å¿ããŠãµã€ããã¢ããªãå€æŽããããšãã«äŸ¿å©
äŸïŒæšªå¹ ã600px以äžã®æã®{}ã«èšèŒããCSSãé©çšããã
@media (max-width: 600px) {
html {
font-size: 87.5%;
}
.header_logo {
width: 60px;
}
.contents {
flex-direction: column;
margin-top: 10px;
}
#main_content,
#sidebar {
width: 100%;
}
}
ð±ã¡ã¿ããŒã¿ã®èšå®
ããŒãžã®ä»å çãªããŒã¿
Description:ã³ã³ãã³ãã«é¢ããç°¡æœã§æ£ç¢ºãªæŠèŠ
SEOã®èŠ³ç¹ã§éèŠãæ€çŽ¢ããããããŒãžã«å
¥ãã
äŸ
<meta
name="description"
content="CSS Cafeã®å
¬åŒãŠã§ããµã€ãã§ããååæ
å ±ãåºè玹ä»ãã¢ã¯ã»ã¹ãäŒç€Ÿæ
å ±ãªã©"
/>
æšæ¥é²ããåã®ãŸãšãããµã¯ããšïŒ
å®ç§ãæ±ãããããšãããªããªäœã«ãããŠãïŒ
å°ããã€ã§ãè«Šããªãããšã倧äºïŒ
ä»é±ãé 匵ããðªð»ãã¯ãŒ
Discussion
SEOãæ°ã«ãªããŸãã
暪ããã³ã¡ã³ã倱瀌ããŸãïŒ
èªåãããããªããªãšæã£ãŠèª¿ã¹ãŠã¿ãŸããïŒ
ïŒseo(æ€çŽ¢ãšã³ãžã³æé©å)ã«åŒ·ããšã¯ïŒ
ïŒgoogleæ€çŽ¢ãšã³ãžã³ãæ å ±ãèªèããããæé©ãªã³ãŒãã£ã³ã°ã§ããã
ããŠãŒã¶ãŒãã¡ãŒã¹ãã§ããããšã
ãâå ·äœçã«ã¯
ããã»èŠåºãã¿ã°ã®æ£ãã䜿çš
ããã»imgã¿ã°ã«altå±æ§ãã€ãã(ïŒç»åãªãããã¹ãã®èªã¿äžã)
ããã»ãªã³ã¯ã®æé©å(<a>ã¿ã°ã«ã¢ã³ã«ãŒããã¹ããããŒã¯ãŒãã®æ¿å ¥ãªã©)ãetc
ã¡ãªã¿ã«HTMLã®Markupã®æå³ã¯ã
âææžæ§é ïŒããã¹ãïŒãèŠèŠè¡šçŸïŒè£ 食ïŒãªã©ã®æ å ±ãã
ã³ã³ãã¥ãŒã¿ãŒãæ£ããèªèã§ããããã«ãã¿ã€ãã«ãèŠåºããªã©ã®åæ§æèŠçŽ ã«ãã¿ã°ããšåŒã°ããèå¥ã®ããã®ç®å°ã䜿ããæå³ä»ããè¡ã£ãŠããããšâ
ãšãããã«ãæ£ããèªèã§ããããã«ãšããæå³ãããããšã«ãæ°ã¥ããŸããïŒ
ãã®ãªã»ããCSSåããŠã¿ãïŒç§ã¯sanitize.cssã䜿ã£ãŠãïŒ
ããã§éãã調ã¹ãŠã¿ããïŒ
ïŒHTML5 Doctor CSS ResetïŒ
ã»äœçœãæåã®èšå®ãå šãŠãªã»ããããã®ã§ãã€ãããèªåã§ãã¶ã€ã³ã§ããã
ãŸã£ãããªç¶æ ãããå šãŠèªåã§ãã¶ã€ã³ã調æŽãããæ¹ã«ãªã¹ã¹ã¡ã
ïŒsanitize.cssïŒ
ã»æçšãªCSSã®ã¿ãæ®ããããã©ã«ãã§ãããªãã«ãã¶ã€ã³ãæŽã£ãŠããããæ軜ã«äœ¿ããã
ã¹ãããªã©ã®ã¢ãã€ã«ã«å¯Ÿå¿ããŠããããšãsanitize.cssã®ç¹åŸŽã®äžã€ã
ã¿ãããªæãã ã£ãïŒ
HTML5 Doctor CSS Resetãšsanitize.cssã®2ã€ã¯äž¡æ¹ãšãä»ã®ãªã»ããcssããããããã§ã
èªåã§å šéšããããããå°ã楜ã«ããããããã£ãŠæããç¬
ãã¡ããã¡ãåããããã説æããããšãïŒïŒïŒ
䜿ãåãã§ããããã«èŠããŠããïŒð¥¹ðð
ãµãããšããããã§ããð¥º