2017-01-15 66 views
1

有没有办法在标签之间添加间距? 这里是一个图像: enter image description here标签之间的间距

我想添加“演示文稿”选项卡和“测试游戏”之间的任何帮助? 下面是我使用的CSS:

* { 
    -fx-focus-color: transparent; 
    -fx-faint-focus-color: transparent; 

    -fx-background-radius: 0; 
    -fx-background-insets: 0; 

    -fx-border-radius: 0; 
    -fx-border-insets: 0; 
} 

/* tabs */ 

.tab { 
    -fx-background-color: linear-gradient(#9b2626, #721b1b); 
    -fx-border-color: #721b1b; 
} 

.tab-label { 
    -fx-text-fill: white; 
} 

.tab:hover { 
    -fx-background-color: #9b2626; 
} 

.tab:pressed { 
    -fx-background-color: #721b1b; 
} 
+0

使用一种无​​形的边界可能?我不知道默认方法。 – Jonah

+0

问题是我已经使用边界... – loryruta

+0

'margin'也许有帮助,对此不太确定。 –

回答

2

未测试,但尝试使用嵌套背景而不是您的边框。这样,您可以在一侧延伸透明背景,创建空间的外观。

* { 
    -fx-focus-color: transparent; 
    -fx-faint-focus-color: transparent; 

    -fx-background-radius: 0; 
    -fx-background-insets: 0; 

    -fx-border-radius: 0; 
    -fx-border-insets: 0; 
} 

/* presentation tab */ 

.tab { 
    -fx-background-color: transparent, tab-border-color , tab-color; 
    tab-color: linear-gradient(light-tab-color, dark-tab-color) ; 
    tab-border-color : dark-tab-color ; 
    dark-tab-color: #721b1b ; 
    light-tab-color: #9b2626 ; 
    -fx-background-insets: 0, 0 5 0 0, 1 6 0 0 ; 
    -fx-padding: 4 10 4 4 ; 
} 

.tab-label { 
    -fx-text-fill: white; 
} 

.tab:hover { 
    tab-color: light-tab-color ; 
} 

.tab:pressed { 
    tab-color: dark-tab-color; 
} 
+0

所有的工作正如我所说的,但你能解释它吗?我会很高兴。 – loryruta

+0

有三个背景,不同的颜色,彼此上面画。有三个相应的插入。因此,透明背景具有零插图,具有边界颜色的背景仅在右侧具有5个像素插入(在另一侧为0),并且具有标签颜色的背景在顶部和右侧插入另一个像素,相对于边框颜色。只需在叠加的图片上绘制一张图片,您会看到效果是在顶部和右侧的1像素边框,以及右侧的5像素透明间隙。填充确保内容不会越过边界。 –

-2

你应该能够做到添加填充或者设置的空间。

// VBox 
VBox vb = new VBox(); 
vb.setPadding(new Insets(10, 50, 50, 50)); 
vb.setSpacing(10); 
+0

似乎不工作... – loryruta

+0

我不知道是否可以通过CSS,如果你找到了我的头上。 –

+0

是的,我发现了-fx-spacing但它不起作用... – loryruta