I have a button with custom CSS. The white background is overflowing and is seen past the black border (as shown in the picture).
I'm not sure how to fix this issue as I have experience only with web version of CSS.
Thanks for any help!
.root {
-fx-font-family: verdana;
-fx-background-color: rgb(16, 118, 252);
}
#head {
-fx-font-size: 30;
-fx-fill: black;
-fx-font-weight: bold;
}
.button {
-fx-background-radius: 50;
-fx-border-radius: 25px;
-fx-text-fill: black;
-fx-background-color: white;
-fx-font-size: 25;
-fx-border-style: solid;
-fx-border-color: black;
-fx-border-width: 5px;
}
#footer {
-fx-font-size: 18;
}
It seems there are some rounding errors for ...-radius styles.
You can hide background under the border by using insets:
-fx-background-insets: 5px;
When vboxs are focased can we use css to change them?
#vbox{
-fx-border-radius:8;
-fx-border-width:2;
-fx-border-color: #333333;
}
//this works
#myvbox:hover {
-fx-border-color: #455A64;
}
//this does not
#myvbox:focused{
-fx-border-color: #000000;
}
Hover works fine. But trying to set color of focused vbox it does not work.
I wan't to change the color of any button in my application from red to blue fluent when the mouse is over it.
This is my css code so far:
.button{
-fx-background-color: rgb(225,0,0);
}
.button:hover{
-fx-background-color: rgb(0,0,255);
transition: -fx-background-color 2s;
}
Now I'm looking for something like this:
.button:hover{
transition: -fx-background-color 2s;
}
Hello Fellow StackOverflow Users, this is my first post/question and hopefully i'm not violating any rules/ect.
Unfortunately I am unable to post a picture, but I will put this here for a reference.
http://i.imgur.com/M0uckkg.jpg (Before Button Click)
OT: On the picture above, I am attempting to make the button's background completely transparent besides the text.
http://i.imgur.com/bFOEOVC.jpg (After Button Click)
Everything works out until I click the button then shadows appear on the side.
Here is what I have tried...
CSS
.toggle-button {
-fx-text-fill: black;
-fx-base: transparent;
-fx-background: transparent;
-fx-focus-color: transparent;
-fx-border-color: transparent;
-fx-effect: null;
}
.toggle-button:selected {
-fx-text-fill: black;
-fx-base: transparent;
-fx-background: transparent;
-fx-focus-color: transparent;
-fx-border-color: transparent;
-fx-effect: null;
}
The java code is just a plain simple application with a ToggleButton.
Special Thanks in Advance!
- Bart
I wouldn't recommend modifing the main color palette (-fx-base and others) for just one control. This makes sense if you're trying to style all of them.
Looking at how is defined in modena.css:
.toggle-button {
-fx-background-color: -fx-shadow-highlight-color, -fx-outer-border,
-fx-inner-border, -fx-body-color;
-fx-text-fill: -fx-text-base-color;
}
.toggle-button:selected {
-fx-background-color: -fx-shadow-highlight-color,
linear-gradient(to bottom, derive(-fx-outer-border, -20%), ...),
linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...);
}
.toggle-button:selected:focused {
-fx-background-color: -fx-focus-color,
linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...),
-fx-faint-focus-color, linear-gradient(to bottom, derive(-fx-color, -22%) 0%, ...);
}
you will need to change all of them: -fx-shadow-highlight-color, -fx-outer-border,...
Instead, I'll just override the style of the toggle button with your requirements:
.toggle-button,
.toggle-button:focused,
.toggle-button:selected,
.toggle-button:selected:focused {
-fx-background-color: transparent;
-fx-text-fill: black;
}
NOTE I've edited my answer since, as #eckig suggests, it's redundant to apply the same color to the different comma separated values.
If you want to remove the button-like optics completely, I would suggest you to remove all existing styles and add your own style class as the only style class:
ToggleButton toggleButton = new ToggleButton("Login");
toggleButton.getStyleClass().setAll("my-custom-button");
Now you can apply only the styles you need:
.my-custom-button {}
Special Thanks to both of you, Jose & Eckig. I managed to edit my code with both your suggestions and it fixed the issue right away!
Here is a reference for anyone in the future.
Button Code
ToggleButton button= new ToggleButton("Login");
button.getStyleClass().add("custom");
CSS
.custom,
custom:selected {
-fx-background-color: transparent;
-fx-text-fill: black;
}
I am trying to hide box-border for tableView. When I hide that border then border for left side of columnHeader is missing.
Here is my css file:
.table-row-cell:empty {
-fx-background-color: lightyellow;
}
.table-row-cell:empty .table-cell {
-fx-border-width: 0px;
}
.table-view{
-fx-focus-color: transparent;
-fx-box-border: transparent
}
Here is image showing what I mean: