使用css的JavaFX按钮可以在没有:hover子句的情况下更改鼠标上的文本aligmen

时间:2019-05-24 18:47:45

标签: java css javafx javafx-8 scenebuilder

我在JavaFx中有一个用CSS样式化的按钮,但是没有“ button:hover”子句。 css中的文本对齐方式设置为右对齐,但有时豌豆左对齐。当我将鼠标悬停在按钮上时,文本对齐方式从左到右变化,并且在CSS中没有关于onMouseOver的内容(或者我认为)。我不知道是否是错误。

CSS:

.button{
    -fx-font-size: 1em;
    -fx-padding: 0 0 -30 0; 
}

.menu, .label{
    -fx-font-size: 0.8em;
}

...

#btPlusLargo{
    -fx-background-color: transparent;
    -fx-background-image: url('../resources/plus.png');
    -fx-text-alignment: right;
    -fx-background-repeat: no-repeat;
    -fx-background-position: left center; 
    -fx-padding: 0 0 0 0;    
}

...

在FXML中

<Button id="btPlusLargo" fx:id="btEntregaTodo" layoutX="773.0" layoutY="532.0" 
        mnemonicParsing="false" onAction="#onClickAgregaTodo" prefHeight="25.0" 
        prefWidth="150.0" stylesheets="@botones.css" text="%bt.AgregaTodo" 
        textAlignment="RIGHT" AnchorPane.bottomAnchor="104.0" 
        AnchorPane.rightAnchor="9.0" />

没有鼠标悬停

将鼠标悬停在上面(必须总是那样。)

0 个答案:

没有答案