Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is trying to set a bright green color for the current (active) language and the hover color for inactive languages in the WPML language switcher, but the site is displaying different colors.

Solution:
We found that there is some CSS on the client's site with the

!important

attribute that is overriding the WPML CSS. We recommend two options:
1. Remove the

!important

attribute from the conflicting CSS.
2. Add the following custom CSS to the theme's custom CSS section:

.wpml-ls-current-language a span, .wpml-ls-item a:hover span {
    color: #9ed60a !important;
}

We also provided a documentation link for further details on how to fix styling and CSS issues for language switchers:
https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/how-to-fix-styling-and-css-issues-for-the-language-switchers/

If the solution provided does not resolve the issue or if the client needs further assistance, we recommend opening a new support ticket. It's also advisable to check related known issues at https://wpml.org/known-issues/, verify the version of the permanent fix, and confirm that the latest versions of themes and plugins are installed.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 4 replies, has 2 voices.

Last updated by Noman 1 year, 1 month ago.

Assisted by: Noman.

Author Posts
April 29, 2024 at 1:54 pm #15577595

dmitriS-6

Tell us what you are trying to do? I set bright green colour as a the default of the current (active) language as well as the hover colour for inactive language - see the screenshot, but the site shows other colours in both cases.

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site? hidden link

Screenshot 2024-04-29 at 16.46.41.png
April 29, 2024 at 2:57 pm #15577893

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting WPML Support. It seems there are some CSS is written on your site with !important attribute which overriding the WPML CSS as you can see in the attached screenshot.

Either you can remove that attribute from CSS or you can simply use the below CSS in the custom CSS section of theme:

.wpml-ls-current-language a span, .wpml-ls-item a:hover span {
    color: #9ed60a !important;
}

And it will look as in the attached screenshot.

Here is a doc for more details: https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/how-to-fix-styling-and-css-issues-for-the-language-switchers/

Please let me know if this resolves the issue or if you need further assistance with this issue.

Thank you

CSS overriding.png
active language.png
April 29, 2024 at 7:52 pm #15578649

dmitriS-6

Thank you, Noman, for your help.

What you sent helped me to achieve the desired effect in the menu (in the header).

1) Frankly I am not good at CSS. I studied the materials you sent. Trying to make a different set of colours and can not make out how to write about the header menu only.

is it wpml-ls-menus-main ? If I set the menu id as "main", right?

2) What I mean is that in the footer there should be white (#ffffff) for the current language and also white for hovering over non-active language (it is a widget - sidebar footer area #6)
Now, according to your code colours there are #9ed60a.

April 29, 2024 at 8:03 pm #15578668

dmitriS-6

Also, I want to add a little margin to the left of language switchers in the main menu of the header. Here is what I wrote, and it seems to be not correct as it is not working.

.wpml-menus-{main}-item {
margin-left: 20px;
}

April 30, 2024 at 7:03 am #15579446

Noman
WPML Supporter since 06/2016

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for the additional details. Could you please remove the previous provided CSS and use this one:

/* Header color */
#menu-main .wpml-ls-current-language a span, #menu-main .wpml-ls-item a:hover span {
    color: #9ed60a !important;
}

/* Footer color */
.wpml-ls-legacy-list-vertical .wpml-ls-current-language a span, .wpml-ls-legacy-list-vertical .wpml-ls-item a:hover span {
    color: #fff !important;
}

/* Header margin */
#menu-main .wpml-ls-first-item {
    margin-left: 20px !important;
}

And see if this resolves the issue.

Thank you

footer switcher2.png
header switcher.png
April 30, 2024 at 12:27 pm #15581281

dmitriS-6

Thanks a lot!