我想通过css更改JavaFX WebView的颜色。我试着这样做
.corner {
-fx-background-color: red;
}
等等
.scroll-pane > .corner {
-fx-background-color: red;
}
但它无法奏效:(帮帮忙!
这是我的FXMl
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.web.*?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<VBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="700.0"
prefWidth="900.0" stylesheets="@../styles/Browser.css" xmlns="http://javafx.com/javafx/8"
xmlns:fx="http://javafx.com/fxml/1" fx:controller="macroapp.classes.controllers.BrowserController">
<children>
<AnchorPane prefHeight="63.0" prefWidth="900.0" style="-fx-background-color: #17181c;">
<children>
<Button fx:id="toMenuOfChoiceButton" layoutX="5.0" layoutY="5.0" mnemonicParsing="false"
onAction="#actionToMenuOfChoice"
prefHeight="42.0" prefWidth="42.0" text="⁞" AnchorPane.leftAnchor="10.0"
AnchorPane.topAnchor="10.0">
<font>
<Font name="System Bold" size="16.0"/>
</font>
</Button>
<Button layoutX="57.0" layoutY="5.0" mnemonicParsing="false" onAction="#actionToBackButton"
prefHeight="42.0" prefWidth="59.0" styleClass="backButton" textAlignment="CENTER"
AnchorPane.leftAnchor="62.0" AnchorPane.topAnchor="10.0">
<font>
<Font size="16.0"/>
</font>
</Button>
<TextField fx:id="browserTextField" layoutX="126.0" layoutY="5.0" maxWidth="700.0"
onKeyPressed="#keyPressedSearchTextField" prefHeight="42.0" prefWidth="543.0"
promptText=" Search..." AnchorPane.leftAnchor="131.0" AnchorPane.topAnchor="10.0">
<font>
<Font size="17.0"/>
</font>
</TextField>
<Button fx:id="collapseButton" layoutX="744.0" layoutY="10.0" mnemonicParsing="false"
onAction="#actionCollapseButton" prefHeight="42.0" prefWidth="42.0" styleClass="collapseButton"
AnchorPane.rightAnchor="114.0" AnchorPane.topAnchor="10.0"/>
<Button fx:id="expandOverlapButton" layoutX="796.0" layoutY="10.0" mnemonicParsing="false"
onAction="#actionExpandOverlapButton" prefHeight="42.0" prefWidth="42.0"
styleClass="expandButton" AnchorPane.rightAnchor="62.0" AnchorPane.topAnchor="10.0"/>
<Button fx:id="closeButton" layoutX="848.0" layoutY="10.0" mnemonicParsing="false"
onAction="#actionCloseButton" prefHeight="42.0" prefWidth="42.0" styleClass="closeButton"
AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0"/>
</children>
</AnchorPane>
<WebView fx:id="browserWebView" prefHeight="637.0" prefWidth="900.0" VBox.vgrow="ALWAYS">
<VBox.margin>
<Insets/>
</VBox.margin>
</WebView>
</children>
</VBox>
这是我的样式表
.button {
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-background-color: #e6e6e6;
}
.backButton {
-fx-background-image: url("../resources/BackBrowser.png");
}
.text-field {
-fx-background-color: whitesmoke;
-fx-background-radius: 11px;
-fx-border-radius: 11px;
-fx-prompt-text-fill: #7a7878;
-fx-border-width: none;
}
.closeButton {
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-background-color: #e6e6e6;
-fx-background-image: url("../resources/Close.png");
}
.overlapButton {
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-background-color: #e6e6e6;
-fx-background-image: url("../resources/Overlap.png");
}
.collapseButton {
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-background-color: #e6e6e6;
-fx-background-image: url("../resources/Collapse.png");
}
.expandButton {
-fx-background-radius: 4px;
-fx-border-radius: 4px;
-fx-background-color: #e6e6e6;
-fx-background-image: url("../resources/Expand.png");
}
.menu-item {
-fx-background-color: #e6e6e6;
-fx-font-size: 18px;
}
.context-menu {
-fx-background-color: #e6e6e6;
-fx-background-radius: 7px;
-fx-border-radius: 7px;
-fx-border-color: black;
-fx-border-width: 0.5px;
}
.menu-item .label {
-fx-text-fill: black;
}
.scroll-bar {
-fx-background-color: #17181c;
}
.thumb {
-fx-background-color: #e6e6e6;
}
.menu-item:hover .label {
-fx-text-fill: #4b4b4b;
}
是截图 Image
IT更多细节)))IT更多细节)))IT更多细节)))IT更多细节)))IT更多细节)))IT更多细节)))IT更多细节) ))IT更详细))