CSS関連の備忘録です。
aタグの後ろにリンクアイコン
target=_new
を検出して自動付与
ブログ内(target=_new
がない)では付与しない
特定の条件をスタイルで指定し、条件に合う時に疑似要素を生成
a
タグ内に[target=_new]
がある場合、after要素を付与してスタイルを指定
.entry-content a[target=_new]:after { content: ''; display: inline-block; background-image: url(アイコン画像のURL); background-repeat: no-repeat; background-size: contain; margin: 0 0.25rem; width: 1rem; height: 1rem; position: relative; top: 0.1rem; }
ページャー(3ページ目)
CSS
/* ページャーを中央に配置 */ .p-article-wp-pager { display: flex; /* Flexboxを使用して要素を水平に配置 */ justify-content: center; /* 水平方向中央に配置 */ align-items: center; /* 垂直方向中央に配置 */ margin: 24px auto; } /* ページ番号を中央に配置 */ .page-numbers-container { display: flex; justify-content: center; } /* ページ番号の通常スタイル */ .post-page-numbers { display: flex; justify-content: center; align-items: center; width: 40px; height: 40px; background-color: #ddd; /* 背景色グレー */ border-radius: 50%; /* 丸い形状にする */ margin: 0 5px; text-decoration: none; /* テキストの下線を非表示 */ color: #333; /* テキストの色をダークグレーに */ font-weight: transition: background-color 0.3s ease, color 0.3s ease; /* ホバー時の色変化を滑らかにするトランジション */ } /* マウスホバー時のスタイル */ .post-page-numbers:hover { background-color: #8a63d2; /* 背景色を紫色に */ color: #fff; /* テキスト色を白に */ } /* 現在(current)の番号スタイル */ p.post-page-numbers.current { background-color: #8a63d2; /* 背景色を紫色に */ color: #fff; /* テキスト色を白に */ margin: auto 5px; /* 左右に5pxのマージン、上下は中央に */ } /* テキストのコンテナスタイル */ .pager-kontena { display: flex; justify-content: space-between; /* 水平方向左右に均等配置 */ margin: 0 auto; max-width: 720px; } /* 左側のコンテンツスタイル */ .yagami-left { text-align: right; width: 50%; margin-right: 10px; } /* 右側のコンテンツスタイル */ .yagami-right { text-align: left; width: 50%; margin-left: 10px; }
HTML
<!-- ページャーのコンテナ --> <div class="p-article-wp-pager"> <!-- ページ番号を含むコンテナ --> <div class="page-numbers-container"> <!-- ページ1へのリンク --> <a href="https://rubirubi.hateblo.jp/entry/csscheatsheet" class="post-page-numbers"> <p>1</p> </a> <!-- ページ2へのリンク --> <a href="https://rubirubi.hateblo.jp/entry/csscheatsheet2" class="post-page-numbers"> <p>2</p> </a> <!-- 現在のページ(ページ3) --> <p class="post-page-numbers current" aria-current="page">3</p> </div> </div> <!-- テキストリンクのコンテナ --> <div class="pager-kontena"> <!-- 左側のリンクテキスト --> <div class="yagami-left"> <a href="https://rubirubi.hateblo.jp/entry/csscheatsheet2">↼ <span style="font-size: 80%">はてなブログ : blog作成備忘録② - CSS Cheat Sheet -</span></a> </div> <!-- 右側のリンクテキスト --> <div class="yagami-right"> <!-- なし --> </div> </div>
^^ 随時追加予定 ---