CSS classes not applied in custom.css file - Forum | JoomShaper
Staff replied Helix Framework

CSS classes not applied in custom.css file

Asked by Michelangelo 1 year ago Last activity 1 year ago

Hi,
I set those classes in a custom.css file I created in \templates\shaper_helixultimate\css folder.

.megamenufoniafacile .sp-dropdown-inner { background-color: #fcc200 !important; border: 2px solid #ffffff !important; left: 0px !important;}
.megamenunavigafacile .sp-dropdown-inner { background-color: #03789E !important; border: 2px solid #ffffff !important;}
.megamenuassistenz .sp-dropdown-inner { background-color: #40b1e2 !important; border: 2px solid #ffffff !important;}

If i set those rules in my external custom.css one of them, in turn, does not work properly and, by using browser inspecting instrument, the css class is not loaded at all while for the other two is correctly loaded.

How is it possible? Is there some setting I've not done?

Thank you

16 replies

Asfakur Rahman Saikat Staff

Hi Michelangelo,

Thank you for reaching out, and sorry for the inconvenience.

Please try clearing both your Joomla cache and browser cache, then test again.

If the issue persists, could you kindly provide Joomla administrator access? This will allow us to investigate the issue more thoroughly. Before sharing your credentials in hidden content, please ensure you've backed up your site using Akeeba Backup.

Thank you for your cooperation. I’ll keep you updated as soon as possible!

Best regards

Michelangelo Asked this

Hi,
and thank you for your answer.
Unfortunately, I'm working on my site on a local XAMPP so I cannot provide you credentials.
By the way.. I cleaned all the caches but the problem is not solved.

The css class
.megamenufoniafacile .sp-dropdown-inner { background-color: #fcc200 !important; border: 2px solid #ffffff !important; left: 0px !important;}

is not loaded in any way, now also in the custom code in the template.
In addition, if I change one of the three classes (for example the name of the class), the last one I modifiy works properly and one of the other two does not.

It seems to be something about a kind of priority or similar.

Asfakur Rahman Saikat Staff

Hi,

It’s possible that your CSS rule isn’t being applied due to incorrect chaining. The CSS should work both in the template’s custom code section as well as in the custom.css file.

You can test the CSS with the following rule:

* {
    background-color: red !important;
}

Could you please let me know where you found the .megamenufoniafacile class or where it’s applied? A screenshot would be helpful to better understand the issue.

Note: It's important to write the CSS rules properly to ensure the style is applied correctly.

Feel free to reach out if you have any further questions.

Best regards

Pavel
1 year ago · edited

The css class .megamenufoniafacile .sp-dropdown-inner .... is not loaded in any way, now also in the custom code in the template.

Hi.

If in your Dev Tools, in the CSS window, you cannot find this element (CSS rule), it can only mean one thing: your selector is incorrect and is targeting a non-existent element, which is why it’s not there. There can be no other reason. It’s your mistake.

Without a link to your website, it’s impossible to help further.

Pavel

The selector .megamenufoniafacile does look suspicious. It’s likely that it should be either .megamenu.foniafacile (if the element has both classes) or .megamenu .foniafacile (if .foniafacile is a child element of .megamenu). Double-check your HTML structure and adjust the selector accordingly.

Michelangelo Asked this

Hi everyone,
I understand that you think it could be my mistake but, honestly, this would not explain why 2 of the 3 classes (which have the same structure) work and 1 does not.
For simplicity, I will explain what I did so you can correct me if necessary.

a) in the custom.css file I created the first rule
.mmfoniafacile .sp-dropdown-inner { background-color: #fcc200 !important; border: 2px solid #ffffff !important; left: 0px !important;}.
Then, I inserted the mmfoniafacile class into the "custom class" of the megamenu. And everything worked

b) I repeated the same thing for the other two rules
.mmavigafacile .sp-dropdown-inner { background-color: #03789E !important; border: 2px solid #ffffff !important;} and
.mmassistenz .sp-dropdown-inner { background-color: #40b1e2 !important; border: 2px solid #ffffff !important;}.

So, in fact, I did nothing more than a copy and paste of the same class structure, modifying, for each one, the background color. Nothing more.

But now, of the 3 rules, 2 work and 1 doesn't.

I don't understand where my mistake is.

Maybe it's better if I tell you what I want to achieve and you give me the correct css code?

Asfakur Rahman Saikat Staff

Hi,

Thank you for your effort.

Please check the main CSS class for the rule that is not being applied.

It seems that the class you applied (possibly .mmassistenz) is not loading. Kindly provide a screenshot of the class where you inserted it and share it with us. Additionally, inspect the element in Google Chrome to verify if the class is loading correctly like this https://prnt.sc/l3HqM0FcfnRh

Compare it with a working class to identify any differences.

Hopefully, this will help you pinpoint the issue.

Best regards

Michelangelo Asked this

Yes, the rule appears in the code but its properties are not loaded

Pavel
1 year ago · edited

Use this button to provide code

Maybe it's better if I tell you what I want to achieve and you give me the correct css code?

I reproduced your steps and everything works fine.

Perhaps you make a mistake somewhere.

For example, here.

Michelangelo Asked this

Hi,
this is the code in my custom.css

.mmfoniafacile .sp-dropdown-inner { background-color: #fcc200 !important; border: 2px solid #ffffff !important; left: 0px !important;}

.mmavigafacile .sp-dropdown-inner { background-color: #03789E !important; border: 2px solid #ffffff !important;}

.mmassistenz .sp-dropdown-inner { background-color: #40b1e2 !important; border: 2px solid #ffffff !important;}

It seems similar to yours.

It also tries to insert "." before the custom class in megamenu setting but it does not work.
Some other css rules goes in conflict ?? It seems strange to me

Pavel
1 year ago · edited

I’m sorry, but without a link to the website, it’s impossible to figure this out. If everything is done correctly, it should work, as you could see from my previous post. I have no other ideas.

It also tries to insert "."

Just in case—this is not correct. There shouldn’t be dots there.

Michelangelo Asked this

Hi,
here it is the screenshot of all the situation.
https://ibb.co/1GvgSvwJ

If you can help me at least to tell me if I've done something wrong, otherwise I'll contact you when I'll put the site online.

Thank you

Pavel

From your screenshot, everything looks correct. The only thing is that left: 0px !important doesn’t make sense in this context. However, it doesn’t affect anything.

Michelangelo Asked this

It is exactly what I thought.

I've just done another test:
I emptied all my custom.css leaving in it only

@media (min-width: 1400px) {
    .container, .container-lg, .container-md, .container-sm, .container-xl, .container-xxl {
        max-width: 1600px !important;
    }
}

.mmfoniafacile .sp-dropdown-inner { background-color: #fcc200 !important; border: 2px solid #ffffff !important;}
.mmavigafacile .sp-dropdown-inner { background-color: #03789E !important; border: 2px solid #ffffff !important;}
.mmassistenz .sp-dropdown-inner { background-color: #40b1e2 !important; border: 2px solid #ffffff !important;}

I cleared all browser cache and all work properly.

As soon as I inserted another rule in my custom.css, for example this

/* personalizzo sfondo topbar */
#sp-top-bar {background: #40B1E2; color: #FFFFFF;}
/* personalizzo sfondo topbar */


/* personalizzo testo topbar */
#sp-top-bar a { color: #FFFFFF;}
#sp-top-bar a:hover { color: #fcc200; }

.sp-contact-info li {
    display: inline-block;
    margin: 0px 10px 0px 0px;
    font-size: 100%;
    white-space: nowrap;
}
/* personalizzo testo topbar */


/* personalizzo social icons */
ul.social-icons {
    list-style: none;
    padding: 0;
    margin: 0;
    display: inline-block;
    font-size: 16px;
}
/* personalizzo social icons */

everithing has become to not work again.
It seems incredible to me.

Pavel

Disable any caching and compression if they are enabled. And when working with CSS, pressing CTRL+F5 to reload the page should be programmed at the instinct level.

Michelangelo Asked this

I always press CTRL+F5 many and many times but I did not check anything about compression.
I'll check and let you know.

Pavel

It’s possible that caching is enabled on your local server.

Michelangelo Asked this

No cache seemst to be enabled.

A stranger thing has just happened.
I tried to assign to the megamenu1 the same css class (.mm-navigafacile) of the megamenu2.
Result: everything works fine.

If I set to megamenu1 his "old class" mm-foniafacile the problem appears again.

Pavel

Check. This should be OFF

Michelangelo Asked this

Already checked before you adviced it to me.
It has always been off.

Pavel

The only thing I can further recommend is to change the class names to simpler ones or separate them with hyphens. It’s easy to make a typo or get confused with such names.

Michelangelo Asked this

This is a very very useful advice that I'll certainly follow from now on.

Log in to reply.