Need a CSS expert... how to change color of a single button?

For support and discussion related to templates, themes, and imagesets in phpBB 3.2.
User avatar
DavideBianchini
Registered User
Posts: 79
Joined: Thu Oct 17, 2019 3:47 am

Need a CSS expert... how to change color of a single button?

Post by DavideBianchini »

Hey guys,
I was wondering if it is possible to apply a CSS color change of individual buttons . Since all buttons seem to share the same class "button," if I make a change to one, they all change color as shown below.

I suppose my question is, can you apply a CSS attribute to an HTML tag (in this case, title="Post a reply")?
(and preferably from my CSS child, without altering core files)
.
button.png

Thanks,

Davide
You do not have the required permissions to view the files attached to this post.
Last edited by DavideBianchini on Fri Oct 25, 2019 11:59 pm, edited 3 times in total.
User avatar
Crizzo
Translations & International Support Teams Manager
Translations & International Support Teams Manager
Posts: 1756
Joined: Thu Apr 23, 2009 1:20 pm
Location: Stuttgart, Germany
Name: Christian

Re: Need a CSS expert... how to change color of a single button?

Post by Crizzo »

Hi,

check the CSS-attribute selector: https://www.w3schools.com/css/css_attri ... ectors.asp 8-)

Regards
My extensions for phpBB: CDB
German phpBB Support at www.phpbb.de
User avatar
DavideBianchini
Registered User
Posts: 79
Joined: Thu Oct 17, 2019 3:47 am

Re: Need a CSS expert... how to change color of a single button?

Post by DavideBianchini »

Crizzo wrote: Fri Oct 25, 2019 10:42 pm Hi,

check the CSS-attribute selector: https://www.w3schools.com/css/css_attri ... ectors.asp 8-)

Regards
Thank you Crizzo, this looks like it could work. I'm just having trouble with the syntax, b/c I get no color change.

Here is what I have for the reply button;

Code: Select all

[title="Post a reply"] {background-color:#87c47d;}
-Davide
User avatar
3Di
I've Been Banned!
Posts: 17538
Joined: Mon Apr 04, 2005 11:09 pm
Location: I'm with Ukraine 🇺🇦
Name: Marco

Re: Need a CSS expert... how to change color of a single button?

Post by 3Di »

That's a style question ;) You might want to ask there in the devoted forum?
🆓 Free support for our extensions also provided here: phpBB Studio
🚀 Looking for a specific feature or alternative option? We will rock you!
Please PM me only to request paid works. Thx. Buy me a coffee -> Image
My development's activity º PhpStorm's proud user º Extensions, Scripts, MOD porting, Update/Upgrades
User avatar
DavideBianchini
Registered User
Posts: 79
Joined: Thu Oct 17, 2019 3:47 am

Re: Need a CSS expert... how to change color of a single button?

Post by DavideBianchini »

3Di wrote: Sat Oct 26, 2019 12:15 am That's a style question ;) You might want to ask there in the devoted forum?
My apologies, I did not see the styles forum. Mods, please feel free to move this topic.

-Davide
User avatar
DavideBianchini
Registered User
Posts: 79
Joined: Thu Oct 17, 2019 3:47 am

Re: Need a CSS expert... how to change color of a single button?

Post by DavideBianchini »

Nevermind, I figured it out, I was missing the "a" prefix. Here is the correct syntax to change just the reply background color;

Code: Select all

a[title="Post a reply"] {background-color:#87c47d;}
Wow this is such a powerful feature of CSS, I never knew this existed before. No longer the need to alter core files!
Hopefully this works in all browsers!

-Davide
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Need a CSS expert... how to change color of a single button?

Post by david63 »

DavideBianchini wrote: Sat Oct 26, 2019 2:14 am No longer the need to alter core files!
How are you applying that if you are not changing core files?
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
PlanetStyles.net
Former Team Member
Posts: 4809
Joined: Wed Nov 04, 2009 11:16 pm
Location: Way up in the sky close to the stars
Name: Christian

Re: Need a CSS expert... how to change color of a single button?

Post by PlanetStyles.net »

david63 wrote: Sat Oct 26, 2019 7:11 am
DavideBianchini wrote: Sat Oct 26, 2019 2:14 am No longer the need to alter core files!
How are you applying that if you are not changing core files?
I think they mean the template files.

Which would make sense, as it's nice to have separate styles applied to New Topic, Post Reply buttons etc, but by default they use the .button class which is widely used elsewhere too.
User avatar
david63
Registered User
Posts: 20646
Joined: Thu Dec 19, 2002 8:08 am

Re: Need a CSS expert... how to change color of a single button?

Post by david63 »

Christian 2.0 wrote: Sat Oct 26, 2019 1:11 pm I think they mean the template files
But template files are core files!
David
Remember: You only know what you know and - you don't know what you don't know!

I now no longer support any of my extensions but they will start to become available here
User avatar
DavideBianchini
Registered User
Posts: 79
Joined: Thu Oct 17, 2019 3:47 am

Re: Need a CSS expert... how to change color of a single button?

Post by DavideBianchini »

david63 wrote: Sat Oct 26, 2019 7:11 am How are you applying that if you are not changing core files?
I am using a child css file, as is common in Wordpress themes. No altering of core files here, not even a style template.

-Davide
Last edited by DavideBianchini on Sat Oct 26, 2019 1:53 pm, edited 2 times in total.
tomberaid
Registered User
Posts: 14
Joined: Wed Dec 20, 2017 8:11 pm

Re: Need a CSS expert... how to change color of a single button?

Post by tomberaid »

Hello
For all languages, test :
a[href*="posting.php?mode=reply"]
User avatar
DTMWC
Registered User
Posts: 379
Joined: Tue Jan 16, 2018 6:17 am

Re: Need a CSS expert... how to change color of a single button?

Post by DTMWC »

Ideally, you need to add a class to the reply/new topic button in the html template file,
Though, some buttons already have classes that you can change them by, the code below could be useful for you experiment with,

Code: Select all

/* Bottom Of Forums & Topics - New Topic Button / Post Reply Button */
.action-bar.bar-bottom .button {
	background: pink;
	border-color: purple;
}

/* Bottom Of Topics - Topic Tools Button */
.action-bar.bar-bottom .topic-tools .dropdown-select.button {
	background: green;
	border-color: red;
}

/* Bottom Of Topics - Quick Mod Button */
.action-bar.bar-bottom .quickmod.dropdown-container .dropdown-select.button {
	background: yellow;
	border-color: blue;
}

/* Bottom Of Forums & Topics - Jump Box Button */
.jumpbox .dropdown-select.button {
	background: red;
	border-color: green;
}

/* Bottom Of Forums - Sorting Options Button */
.action-bar.bar-bottom .sort-tools .dropdown-select.button {
	background: brown;
	border-color: orange;
}
Image

The new topic / post reply button doesn't have a class so it would basically change all the buttons, but the buttons at the side of it have their own classes, we address them with: .action-bar.bar-bottom so only the buttons in the bottom action bar be effected.
To address the top action bar buttons it would be: .action-bar.bar-top

This code would be added to the bottom of the colours.css style sheet, change the colours to whatever you want, one thing I don't recommend is using !important - if you find you need to use it to get something to work - there should be another way to do it without using it.

The method posted by @tomberaid is a better way of changing just the reply button.
Boom.

Return to “[3.2.x] Styles Support & Discussion”