3-4. footer部分のCSSを書く
このチャプターでは、footer
要素のCSSを記述していきます。
テキスト位置を調整する
footer
要素のテキスト位置を調整します。
以下は記述するCSSです。
/* ============================ */
/* .footer
/* ============================ */
.footer {
text-align: center;
}
.footer small {
font-size: 0.85em;
}
テキストを中央寄せにし、フォントサイズを少し小さくしています。
この状態でstyle.css
を保存し、index.html
をブラウザで開くと、以下のように表示されます。
footer
要素のCSSは以上です。
ここまでに記述したコード
ここまで記述したCSSファイルの中身です。
@charset "utf-8";
/* font@google */
@import url('https://fonts.googleapis.com/css2?family=Fascinate+Inline&display=swap');
/* ============================ */
/* reset
/* ============================ */
body, p, h1, h2, h3, ul, li, figure, small {
margin: 0;
padding: 0;
}
* {
box-sizing: border-box;
}
img {
vertical-align: middle;
max-width: 100%;
height: auto;
}
/* ============================ */
/* base
/* ============================ */
:root {
--baseColor: #143d60;
--subColor: #eb5b00;
--whiteColor: #fefefe;
--bgColor: #fdfbee;
}
html {
scroll-behavior: smooth;
}
body {
color: var(--baseColor);
font-size: 1rem;
font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
line-height: 1.8;
background-color: var(--bgColor);
}
h1,
h2 {
margin-bottom: 10px;
color: var(--subColor);
font-weight: 400;
font-style: normal;
font-family: 'Fascinate Inline', system-ui;
text-align: center;
}
/* ============================ */
/* link
/* ============================ */
a {
transition: all 0.3s;
}
a:link,
a:visited {
color: var(--baseColor);
text-decoration-line: underline;
text-decoration-color: var(--subColor);
/* text-decoration: underline var(--subColor); /* Safari以外は一括指定でも可 */
}
a:hover,
a:active {
color: var(--subColor);
text-decoration: none;
}
/* ============================ */
/* .wrapper
/* ============================ */
.wrapper {
margin: 40px auto;
width: 90%;
max-width: 550px;
/* width: min(90%, 550px); /* ←まとめてこのように書くこともできます */
}
/* ============================ */
/* .header
/* ============================ */
.header {
margin-bottom: 40px;
}
h1 {
font-size: 2.5em;
}
.prof_icon {
margin: 0 auto 20px;
width: fit-content;
border-radius: 50%;
overflow: hidden;
}
/* ============================ */
/* .main
/* ============================ */
.main {
margin-bottom: 40px;
}
h2 {
font-size: 2.25em;
}
.main ul li {
margin-bottom: 15px;
list-style: none;
}
.main ul li a {
padding: 15px 50px 15px 15px;
text-decoration: none;
background-color: var(--whiteColor);
border: 1px solid var(--baseColor);
border-radius: 5px;
position: relative;
display: block;
}
.main ul li a:hover {
color: var(--subColor);
border-color: var(--subColor);
}
.main ul li h3 {
font-size: 1.15em;
}
.main ul li h3 .ph-fill {
margin-right: 5px;
}
.main ul li a > .ph-fill {
margin-block: auto;
font-size: 18px;
width: 18px;
height: 18px;
position: absolute;
inset-block: 0;
right: 15px;
}
/* ============================ */
/* .footer
/* ============================ */
.footer {
text-align: center;
}
.footer small {
font-size: 0.85em;
}
以上でプロフィールページのCSSはいったん終わりです。おつかれさまでした。
最後にスマホで見た目を確認し、少し調整を行います。
参考情報など
このチャプターでの参考情報はありません。