0

I use the following code which get applied on two different pages because both pages are using the same element:

.SocialBar {
display: none;
} 

But I want the code to be applied to one page only. On the page where I want it, the following class exists:

.PersonalHome-interests.u-mbg

Is it somehow possible that I insert .PersonalHome-interests.u-mbg over the thing with the Newsticker and only let check whether the line PersonalHome-interests.u-mbg exists and if so, then Newsticker = display: none apply?

Thanks.

3
  • By the way, I use Stylish / Stylus. A good solution would be @-moz-document url but the problem is that it's the same url for both pages, you can just switch between two designs and I just want the change at one view. Commented Jan 25, 2018 at 1:37
  • I'm a little confused as to what your'e asking. You want to hide elements that have both the classes .SocialBar and .PersonalHome-interests, but show elements that only have the class .SocialBar? Commented Jan 25, 2018 at 1:39
  • If you have the CSS that has .SocialBar linked to web page, it will affect that page, unless you overwrite it. If you only want .PersonalHome-interests.u-mbg.SocialBar{ display:none; } on the CSS page that is used for multiple HTML pages, then do that. Commented Jan 25, 2018 at 2:04

1 Answer 1

1

I'm a little confused as to what your'e asking, but assuming you're asking how you can hide elements that have both the classes .SocialBar and .PersonalHome-interests, but show elements that only have the class .SocialBar, all you need to do is combine the class selectors into one as .SocialBar.PersonalHome-interests.u-mbg, and hide that.

Because you're specifically targetting elements that have both classes, the element that only has one of the two classes will not have the display: none rule apply to it (and so it will remain visible).

This can be seen in the following:

.SocialBar.PersonalHome-interests.u-mbg {
  display: none;
}
<div class="SocialBar">Visible</div>
<div class="SocialBar PersonalHome-interests u-mbg">Hidden</div>

Hope this helps! :)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for you help :)

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.