jcoppens
jcoppens

Reputation: 5440

GTK3 CSS colors not respected - even in official example

I've been suffering with a simple task: I want to make a GtkLabel's background and text another color. I've read many pages, and as such also tried to put an EventBox behind the label and changeing the box's bg color instead. All to no avail.

Then I came across this tutorial, which I copied, compiled without change, and it has the same problem: The background isn't yellow, and the text isn't blue, as they are supposed to be. I even tried replacing the 'yellow' color by rgba(255, 127, 127, 1) to be sure there was no transparency.

An extra fact: The font is being changed correctly! So the CSS is really being interpreted.

So, why doesn't this work? (I've come across another user with the exactly same problem - no solution though).

Suspecting: is it possible that the theme is somehow blocking later changes? I would suppose that later defined CSS should override any theme definition?

Note: I'm using gtk 3.12.2

Edit: I Changed the theme to default Adwaita, and the background changed to light, but not to the color indicated in the program. The text color did not change. Screenshot with Adwaita theme

Upvotes: 0

Views: 1556

Answers (3)

tst
tst

Reputation: 11

I came across a similar problem - for me, putting:

background-image: none;

into my CSS resolved the situation - I guess some themes have background images which block the background color from being displayed

Upvotes: 1

mike
mike

Reputation: 1175

With some themes you might need "background" instead of "background-color".
Set the hover background color of a Gtk3 MenuItem

As far as the text color being ignored, it might be due to the theme. Try another theme, and/or try one of the other color units. CSS for Gtk3 works with: Basic color keywords, X11 extended, RGB(integers or integer percentages), RGBA and hexadecimal.

According to the GTK+ roadmap all style properties will be deprecated after 3.18 and before 4.0 anyway. https://wiki.gnome.org/Projects/GTK+/Roadmap

They were supposed to be merging Clutter into GTK+ by v4.0 but now I hear things about GSK so I don't know what their going to do. https://www.bassi.io/articles/2014/07/29/guadec-2014-gsk/

Upvotes: 0

user3629249
user3629249

Reputation: 16540

to start, it strongly depends on which colour pallet is selected/default.

second, colour bytes are defined as 0...255, not 0.5

Upvotes: 0

Related Questions