XF 2.2 How to change the background color of @-quoted usernames in a post?

ShikiSuen

Well-known member
I tried the following LESS but it doesn't work:
Less:
/* ===== Quoted Usernames =====*/
[data-xf-init^="member-tooltip"]{
    .username {background-color: @xf-textColor;}
}
 
Last edited:
I tried the following LESS but it doesn't work:
Less:
/* ===== Quoted Usernames =====*/
[data-xf-init^="member-tooltip"]{
    .username {background-color: @xf-textColor;}
}}

Can you try this, then? ▼ In extra.less template. Using your preferred color, of course, adapting for your theme's color.

Code:
/*Username quote background*/

#js-XFUniqueId115.username {
    background-color: #555555 !important;
}

It shows like this for me. On Dark theme.


4eb08788ced18f27f9d4259a5457b4ea.png

On Light theme.

8f18d8c4a29be47b60eb61d17c90ac6a.png

IMPORTANT - I got the usernames IDs by using the Inspect (or F12) function. In my case, they showed as 115 (dark theme) and 118 (light theme).


Good luck!
 
Last edited:
Thanks for your trick. Unfortunately, the UniqueID varies among contexts.
View attachment 269404

Brogan has a better one! :)

EDIT: And if you have more than one color theme (like me), you simply change the background color in the specific theme's template.

I also added a padding: 2px 3px; in order to get a bit of color around it too, so that the colored box wouldn't cut so sharply so close to the username. I also added a border-radius 25px.

So here is my full code for this.

Code:
/*Username quoted background*/

[data-template*="thread_view"]
{
    .bbWrapper .username
    {
        background-color: #4f5766;
        padding: 2px 4px;
        border-radius: 25px
    }
}


It works perfectly! Thank you, Brogan! (y)(y)(y)

And thank you @ShikiSuen for the great idea! :)
 
Last edited:
I also added a padding: 2px 3px; in order to get a bit of color around it too, so that the colored box wouldn't cut so sharply so close to the username. I also added a border-radius 25px.

So here is my full code for this.

Code:
/*Username quoted background*/

[data-template*="thread_view"]
{
    .bbWrapper .username
    {
        background-color: #4f5766;
        padding: 2px 4px;
        border-radius: 25px
    }
}
Apologies for the dumb question here, where does this code need to be inserted?
I have tried it in the extra.less but it has no effect.
 
Generally in extra.less. If they aren't taking effect, you may want to use an !important in the LESS code.
Also, if you have multiple styles, be sure you are working in the one you want it to take effect in.
Just tried this and it still doesn't work,

Code:
/*Username quoted background*/

[data-template*="thread_view"]
{
    .bbWrapper .username
    {
        background-color: #4f5766;
        padding: 2px 4px;
        border-radius: 25px !important;
    }
}
 
Just tried this and it still doesn't work,
Link to site (specifically a post utilizing that function that guests can view). You can get more help that way, especially if you are running a 3rd party style.
Realize also that post you quoted data from is almost a year old... so some data may have changed... are you specifically wanting it ONLY on the thread view?
 
Realize also that post you quoted data from is almost a year old... so some data may have changed... are you specifically wanting it ONLY on the thread view?
My apologies, all works with this now, it was me miss reading the title of this thread. I realise this is for something totally different.

What I am trying to achieve is to change the background colour of a quoted message and also the font colour of the user name in the quote.
 
Hope I'm not too late responding.

Not sure if you found a solution for the background color for the quotes, but look in your admin panel, under Appearance, in BBCode Elements, find BB code blocks. Under Background, is where you set the color.

1351c10590400f1ae4dd364bbd6a7f5d.webp

I picked Alternate content background color. It's part of Xenforo color convention, not an hexadecimal in this case.

41201a1ec8216515ccb940143e8fe3b9.webp

I don't know how you could change the font color specifically for the BBCode quote, though.

Good luck!
 
Hope I'm not too late responding.

Not sure if you found a solution for the background color for the quotes, but look in your admin panel, under Appearance, in BBCode Elements, find BB code blocks. Under Background, is where you set the color.

View attachment 287282

I picked Alternate content background color. It's part of Xenforo color convention, not an hexadecimal in this case.

View attachment 287283

I don't know how you could change the font color specifically for the BBCode quote, though.

Good luck!
You just put Brogan's code into the end of your Extra.less template, and the thing gets done.
 
Back
Top Bottom