0

Sample theme: https://martfury03.magebig.com/

I need on category page: https://martfury03.magebig.com/consumer-electric.html

Change bg color.

So I add custom css change code:

.page-wrapper {
    background: black;
}

enter image description here

But when I save this custom css, then the color on the home page will also change, the color on the product card, the color in the shopping cart, etc.

(naturally because this element .page-wrapper is present on all pages)

and here I have a question, (I cannot interfere with .phtml files to rename e.g. .page-wrapper-2 on category page.

  1. Is there any other way to only apply a color changes to category page example via pure css code? (so that it has no confilict on other pages)?

3 Answers 3

3

It seems that, when you enter in a category, you have an HTML code like this:

<body class="... catalog-category-view ...">
   ...
   <div class="... page-wrapper ...">
   ...
   </div>
   ...
</body>

Maybe you could use a CSS selector like this:

.catalog-category-view > .page-wrapper {
    background: black;
}
Sign up to request clarification or add additional context in comments.

2 Comments

Really thanks, it works great! I just wanted to ask you about one thing. Because you can see below .row { } prnt.sc/10yxz0e I would also like to set the margin to 0px for the product category only. I try use this code: .catalog-category-view > .row { margin-right: 0px; margin-left: 0px; } but in this case it doesn't work. Could you give me a hint? Thanks!
If the element with the .row class is not a direct descendant of the body, then you should use a selector like this: .catalog-category-view .row {}
3

After reviewing the html body through Google Chrome's Developer tools, I've noticed that the body itself changes classes according to the category you're searching in... Therefore you can simply make use of "body.category-consumer-electric" tag as the parent to .page-wrapper. Like so:

body.category-consumer-electric .page-wrapper {
    background: black;
}

Do note that you shouldn't use ">" merely a " ", because we don't want it to be a direct child.

If you require more direction in regards to CSS selectors, I recommend taking a look at W3Schoools' CSS tutorials.

Hopefully this answers your question.

Comments

2

If you have access to the code you should add another class on the element you want to change and define the CSS rules you want just on that specific class. You could use the "magebig-container" if it's only used on that page

If you don't have access to the code you could be much more specific on the element you want to change with "CSS Selectors" so in your CSS file you could do for example:

div > p 

Selects all < p > elements where the parent is a element

You can do that with classes too!
For example in your case:

.category-consumer-electric >.magebig-container{
background: black;

}

Selects loading-mask where the parent is .magebig-container

For more CSS Selectors you could check: CSS Selectors here.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.