簡體   English   中英

如何使用 JavaFX CSS 刪除帶有嵌套標簽的按鈕的填充

[英]How to remove the padding of a button with nested label with JavaFX CSS

如您所見,標簽(“a123”)嵌套在按鈕中。 由於標簽具有背景顏色,我希望它能夠吞沒按鈕的整個高度和左側。 你能建議正確的方法嗎?

現在的情況:

在此處輸入圖片說明

期望:

在此處輸入圖片說明

我的解決方案:

<Button fx:id="rootContainer" alignment="TOP_LEFT" graphicTextGap="10.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="30.0" prefWidth="190.0" stylesheets="@../../../commons/util/resources/myCSS.css" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="app.features.dashboard.userorder.UserOrderPresenter">
    <graphic>
        <HBox alignment="CENTER" spacing="10.0">
            <children>
                  <Label fx:id="labelTableName" alignment="CENTER_RIGHT" contentDisplay="CENTER" focusTraversable="false" maxHeight="1.7976931348623157E308" maxWidth="-Infinity" prefWidth="70.0" styleClass="label-table-number" text="a123" textFill="WHITE">
                      <HBox.margin>
                          <Insets bottom="-8.0" left="-15.0" top="-8.0" />
                      </HBox.margin>
                  </Label>
                <HBox alignment="CENTER_LEFT" spacing="5.0" HBox.hgrow="ALWAYS" />
            </children>
        </HBox>
    </graphic>
</Button>

你可以嘗試負利潤率。

文件格式

<?xml version="1.0" encoding="UTF-8"?>

<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.StackPane?>


<StackPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
   <children>
      <Button mnemonicParsing="false" prefHeight="25.0" prefWidth="77.0">
         <graphic>
            <HBox>
               <children>
                  <Label maxHeight="1.7976931348623157E308" style="-fx-background-color: black; -fx-text-fill: white;" text="Label">
                     <HBox.margin>
                        <Insets bottom="-3.0" left="-7.0" right="-3.0" top="-3.0" />
                     </HBox.margin>
                     <padding>
                        <Insets left="5.0" right="5.0" />
                     </padding>
                  </Label>
               </children>
            </HBox>
         </graphic>
      </Button>
   </children>
</StackPane>

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM