2017-01-15 225 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