简体   繁体   English

JavaFX CSS:更改TabPane Tab标头形状

[英]JavaFX CSS: Change TabPane Tab header shape

I am trying to change the Tab header shape in css , but when I look at the css reference for JavaFX in here , I can't find what are the accessible properties of a Tab through css . 我试图更改cssTab标题形状,但是当我在这里查看JavaFXcss参考时,找不到通过css的Tab的可访问属性。 I want to have a trapezoid shape instead of a rectangle. 我想使用梯形而不是矩形。 Any idea how to accomplish this task? 任何想法如何完成此任务?

You can check the default modena.css in any case: 您可以在任何情况下检查默认的modena.css

Tab s have the CSS class: .tab-pane > .tab-header-area > .headers-region > .tab Tab具有CSS类: .tab-pane > .tab-header-area > .headers-region > .tab

So for example adding the following to your CSS file: 因此,例如,将以下内容添加到您的CSS文件中:

.tab-pane > .tab-header-area > .headers-region > .tab {
    -fx-background-radius: 20;
}

.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
    -fx-border-radius: 20;
}

will result in the following: 将导致以下结果:

在此处输入图片说明

For trapezoid you need to use the -fx-shape attribute: 对于梯形,您需要使用-fx-shape属性:

.tab-pane > .tab-header-area > .headers-region > .tab {
      -fx-shape: "M300,290 L310,168 L410,168 L421,290 L300,290 z";
}

.tab-pane:focused > .tab-header-area > .headers-region > .tab:selected .focus-indicator {
    -fx-shape: "M300,290 L310,168 L410,168 L421,290 L300,290 z";
}   

which will result in: 这将导致:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM