0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

EC-CUBEで特定ページのみCSSを反映したい

Posted at

基本環境

EC-CUBE4.2.2

EC-CUBEでのCSSカスタマイズ

デフォルト仕様

root/html/twmplate/default/assets/css/style.css

カスタマイズ仕様

root/html/twmplate/default/assets/css/style.css
↓
root/html/user_data/assets/css/customize.css

customize.cssが後から読み込まれ優先される

特定ページだけカスタマイズしたい場合

そのページのtwigの{% block main %}より上に{% block stylesheet %}を設置してCSSコードを記述

{% block stylesheet %}
    <style>
        セレクタ {
            プロパティ: 値;
        }
        .ec-layoutRole__main {
            background: #c0c0c0 !important;
        }
    </style>
{% endblock %}

{% block main %}

{% endblock %}

twig内<style>が反映されない

同じセレクタ指定が

style.css
customize.css
twig内<style>

に存在する場合、

twig内<style>(最優先)
   ↓
style.css(優先)
   ↓
customize.css

の順で読み込まれるようだ

twig内<style>を反映させるには

<style>
        セレクタ {
            プロパティ: 値 !important;
        }
</style>

値に!importantを追加する

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?