当サイトではヘッダーをはじめ色んな背景色をグラデーションにしています。
SWELLで背景色をグラデーションするには多くの箇所でCSSが必要です。
今回はSWELLにある色んなコンテンツの背景色をグラデーションする方法を紹介します。
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
CSSを使わない設定も紹介しています。
当サイトと同じ全ての箇所をカスタマイズ
当サイトで現在当てている設定を再現する際は以下のCSSをコピペしてください。(色探しはこちらの記事から)
:root {
--color_header_bg: var(--color_main_new);
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.c-categoryList__link, .c-postThumb__cat, .c-widget__title.-side, .cap_box_ttl, .is-style-balloon_box, .is-style-num_circle li::before, .post_content h2, .p-toc__ttl, .l-footer, .u-bg-main, [data-type=type2] .p-blogCard__caption, [class*=is-style-btn_] a{
background: var(--color_main_new);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
貼り付け場所はページ下部に記載しています。
現在当サイトでは以下のコンテンツで背景色をグラデーションしています。
- ヘッダー
- カテゴリーリンク
- ブログカードアイキャッチのカテゴリー
- サイドバーウィジェットのタイトル
- キャプションボックスのタイトル
- 段落の吹き出し
- リストの丸数字
- H2見出し
- フッター
- ステップの数字
- あわせて読みたい
- ボタン各種
CSS解説
今回紹介したCSSを簡単に解説します。アレンジなどの参考にしてください。
- カスタムプロパティ
-
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
CSS変数とも呼ばれる再利用が可能なスタイルです。
そらしどSWELL自身も様々な色やサイズをカスタムプロパティで設定しています。
- カスタムプロパティの疑似クラス
-
:root { }
カスタムプロパティを「:root」定義すると、 HTML全体で使用することができます。
- 線形グラデーション
-
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
指定した二つの色をグラデーションで表現します。
今回指定している値は左から
- 135deg…angle(角度)
- #3b4675 10%…開始から10%までの色を指定
- #2F80ED 100%…続きから100%までの色を指定
個別にカスタマイズ
次にサイトの一部だけCSSを反映したい場合を紹介します。
次の部分は共通で1つあればいいので、2箇所目以降では割愛してください。
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
ヘッダー
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/color_header_bg_pc-800x40.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/color_header_bg_pc-800x40.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/color_header_bg_sp.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/color_header_bg_sp.png)
:root {
--color_header_bg: var(--color_main_new);
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
ヘッダーはカスタムプロパティを上書きすることで反映することができます。
カテゴリーリンク
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-categoryList__link.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-categoryList__link.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.c-categoryList__link a{
background: var(--color_main_new);
}
ブログカードアイキャッチのカテゴリー
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-postThumb__cat.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-postThumb__cat.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.c-postThumb__cat a{
background: var(--color_main_new);
}
サイドバーウィジェットのタイトル
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-widget__title.-side.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/c-widget__title.-side.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.c-widget__title.-side a{
background: var(--color_main_new);
}
キャプションボックスのタイトル
![キャプションボックス(SWELLの様々な背景色をグラデーションする方法)](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/cap_box_ttl_1.png)
![キャプションボックス(SWELLの様々な背景色をグラデーションする方法)](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/cap_box_ttl_1.png)
![キャプションボックス枠上2](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/cap_box_ttl_2.png)
![キャプションボックス枠上2](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/cap_box_ttl_2.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.cap_box_ttl a{
background: var(--color_main_new);
}
段落の吹き出し
![段落の吹き出し](https://soracidblog.com/subtheme/wp-content/uploads/2022/03/is-style-balloon_box.png)
![段落の吹き出し](https://soracidblog.com/subtheme/wp-content/uploads/2022/03/is-style-balloon_box.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.is-style-balloon_box a{
background: var(--color_main_new);
}
「吹き出し2」はクラスが別なので、そちらもカスタマイズしたい場合は別途指定が必要です。
リストの丸数字
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/is_style_num_circle.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/is_style_num_circle.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.is-style-num_circle li::before a{
background: var(--color_main_new);
}
見出し2
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/post_content_h2.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/post_content_h2.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.post_content h2 a{
background: var(--color_main_new);
}
当ブログでは見出し2のデザインに「帯」を使用しています。別のデザインの場合はうまく反映されない場合があります。
- カスタマイズ画面
- 投稿・固定ページ
- コンテンツのデザイン
フッター
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/l_footer_pc-800x30.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/l_footer_pc-800x30.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/l_footer_sp.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/l_footer_sp.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.l-footer a{
background: var(--color_main_new);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
フッターはヘッダーと違いカスタムプロパティからでは反映できなかったためクラスを指定しています。
ステップの数字
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/u_bg_main.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/u_bg_main.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
.u-bg-main a{
background: var(--color_main_new);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
名前から察するに他にも反映されるかもしれません。
あわせて読みたい
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/p_blogCard__caption1.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/p_blogCard__caption1.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
[data-type=type2] .p-blogCard__caption a{
background: var(--color_main_new);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
[data-type=type2]はブログカード(内部)の設定です。
- SWELL設定
- エディター設定
- その他
ボタン各種
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/is_style_btn_.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/is_style_btn_.png)
:root {
--color_main_new :linear-gradient(135deg,#3b4675 10%,#2F80ED 100%);
}
[class*=is-style-btn_] a{
background: var(--color_main_new);
}
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
SWELLボタンは設定画面からグラデーションできます。
これはプロフィール欄のボタン等用です。
CSS不要でグラデーションできるコンテンツ
SWELLの中にもCSSを使わずにグラデーションできるコンテンツがいくつかあります。
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/09/7672_color-e1631953644709.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/09/7672_color-e1631953644709.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/09/7672_color-e1631953644709.png)
CSSは使いたくないけど少しでもグラデーションしたい
という方はこちらだけでも設定してみましょう。
SWELLボタン
SWELL利用者御用達のSWELLボタンはグラデーション設定があります。
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/setting_swell_btn-800x443.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/setting_swell_btn-800x443.png)
ノーマルボタンとキラッとボタンで設定できます。
\ノーマルボタン/
\ キラッとボタン /
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
値は上記で紹介しているカラーコードで大丈夫です。
CSSを張り付ける場所
当サイトでは追加CSSに記載しています。
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/css_add.png)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/12/css_add.png)
- カスタマイズ画面
- 追加CSS
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
こだわりがなければ、SWELLで子テーマは必要ないと思っています。
子テーマの記載場所はこちらの記事から。Cocoonの内容ですが、CSSの貼り付け場所はほぼ一緒です。
子テーマの場合はテーマエディタからも編集できますが、注意が必要です。
当サイトで掲載しているソースコードについて
この記載はプライバシーポリシーからの抜粋です。
著作権およびライセンス
ブログに掲載されている、ブログ管理者(そらしど)が本来権利を有するソースコードについては、ライセンスをCC0とします。
商用・非商用を問わず自由に利用していただいて構いません。その際の連絡も不要です。
免責事項
当サイトに掲載しているカスタマイズ情報のご利用にあたっては、必ずカスタマイズするファイルのバックアップをご用意の上、ご利用者様責任において実施していただきますようお願いいたします。
カスタマイズの実施により生じたいかなる不具合等についても当サイトその責任を負いかねます。何卒ご理解、ご了承の上、当サイトをご活用いただきますようお願い申し上げます。
まとめ
SWELLサイトの色んな背景色をグラデーションさせる方法を紹介しました。
色や角度などを自分好みにアレンジできるので、自分だけのサイト作りの助けになれば幸いです。
掲載されていないコンテンツの背景色を変えたい場合はF12開発者ツールを使って探すのがおすすめです。
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
![](https://soracidblog.com/subtheme/wp-content/uploads/2021/04/kinei_20210418-1-e1618745751482.jpg)
最後まで読んでいただきありがとうございました。