My problem is simple. I would like to change the color of each category's header. For example, the first category could be red, the next category below it could be yellow.
3 posters
Different Colors For Each Category
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°1
Different Colors For Each Category
SLGray- Administrator
- Posts : 51498
Reputation : 3523
Language : English
Location : United States
- Post n°2
Re: Different Colors For Each Category
Do you mean the backgrounds or the titles?
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°3
Re: Different Colors For Each Category
The backgrounds.
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°4
Re: Different Colors For Each Category
Hi @Forumedic,
This can be done by using a bit of JavaScript and CSS. Go to Modules > JS codes management > Create a new script
Placement : In the homepage
The variable you should focus on modifying is the
object :
To the left of the colon is the category name, and to the right of the colon is the class you want added to this category. Make sure to separate these pairs by a comma. Note that the last pair in the object doesn't need a comma, unless of course you add another pair after it. When you're finished editing make sure to save.
After this you can use CSS to modify the category style attributes.
flag to override styles. That is if your rule doesn't take effect.
If any questions let me know.
This can be done by using a bit of JavaScript and CSS. Go to Modules > JS codes management > Create a new script
Placement : In the homepage
- Code:
$(function() {
var forum = {
'Main' : 'category-main',
'Features' : 'category-features'
},
a = $('.forabg'), i = 0, j = a.length, k, txt;
for (; i < j; i++) {
txt = a[i].getElementsByTagName('H2')[0].innerHTML.toLowerCase();
for (k in forum) {
if (txt == k.toLowerCase()) {
a[i].className += ' ' + forum[k];
break;
}
}
}
});
The variable you should focus on modifying is the
|
- Code:
var forum = {
'Main' : 'category-main',
'Features' : 'category-features'
},
To the left of the colon is the category name, and to the right of the colon is the class you want added to this category. Make sure to separate these pairs by a comma. Note that the last pair in the object doesn't need a comma, unless of course you add another pair after it. When you're finished editing make sure to save.
After this you can use CSS to modify the category style attributes.
- Code:
.category-main {
background-color:#8C5;
border-color:#7B4;
}
|
If any questions let me know.
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°5
Re: Different Colors For Each Category
Didn't work. Where shoukd I put the "!important"?
I did this:
I did this:
- Code:
.category-main { !important
 background-color:#f04c25;
 border-color:#f04c25;
}
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°6
Re: Different Colors For Each Category
It should go at the end of the property value. e.g. :
Info : https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
- Code:
selector {
property:value !important;
property:value;
}
Info : https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°7
Re: Different Colors For Each Category
Did it, didn't seem to work either.
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°8
Re: Different Colors For Each Category
The URL of your forum this is applied to ?
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°9
Re: Different Colors For Each Category
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°10
Re: Different Colors For Each Category
There's an error in the script. Add a comma after this :
and this :
and it should be good.
- Code:
'Features':'category-features'
and this :
- Code:
'Discussion':'category-discussion'
and it should be good.
Take Notes- Helper
- Posts : 2337
Reputation : 324
Language : English
Location : Forumountain
- Post n°11
Re: Different Colors For Each Category
Yes! Thank you very much!
Solved!
Solved!
Ange Tuteur- Forumaster
- Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania
- Post n°12
Re: Different Colors For Each Category
You're welcome !
Topic archived
Have a good weekend.
Topic archived
Have a good weekend.