Since there seems to be very little info on how views are referenced in a CSS file, I decided to create this thread so that, me as well as others, can easily find them.
Hopefully, this will become a sticky...
As we all know, B4J app are highly customizable using CSS.
In this thread we will customize a menubar appearance, changing it from this:
into this:
So, the magic happens in the CSS file, like this:
Here we changed the MenuBar appearance itself, by referencing ".menu-bar", giving it a soft gradient; from white down to a light-bluish color
Next we change the Hover and Showing states of the root menu items holder, in this case, "File";"Edit" & "help". We gave it a basecolor, layered with two gradients; added insets, rounded just a tad the corners and finished with a nice shadow effect.
Since the default style (Caspian.css) changes the textcolor from black to white when hovered, we override it and force it to always be black, by changing the Label text color (.menu .label)
Here we give the same style to the menu sub-items just to keep things neat.
Hopefully more examples will be added here, feel free to contribute.
Hope you enjoy.
Hopefully, this will become a sticky...
As we all know, B4J app are highly customizable using CSS.
In this thread we will customize a menubar appearance, changing it from this:
into this:
So, the magic happens in the CSS file, like this:
B4X:
/********************************
* MenuBar1 styling *
********************************/
.menu-bar
{
-fx-background-color: linear-gradient(#ffffff, #e8f5fc);
}
B4X:
.menu:hover, .menu:showing
{
-fx-background-color:
#3c7fb1, linear-gradient(#fafdfe, #e8f5fc),linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
-fx-background-insets: 0,1,2;
-fx-background-radius: 3,2,1;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
}
B4X:
.menu .label
{
-fx-text-fill: black;
}
B4X:
.menu-item:hover, .menu-item:focused
{
-fx-background-color:
#3c7fb1, linear-gradient(#fafdfe, #e8f5fc),linear-gradient(#eaf6fd 0%, #d9f0fc 49%, #bee6fd 50%, #a7d9f5 100%);
-fx-background-insets: 0,1,2;
-fx-background-radius: 3,2,1;
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 );
}
Hopefully more examples will be added here, feel free to contribute.
Hope you enjoy.
Last edited: