问题描述
就我而言,我想实现完全相同的目标,但不知道该怎么做。
.apply-button {
position: absolute;
margin-top: 8rem;
border-radius: 5em;
Box-shadow: 0 8px 4px 0 rgba(0,0.25);
border-style: solid;
border-width: 0.275rem;
border-image-slice: 0;
border-image-source: linear-gradient(to top,#0270bb,#c6e357,rgba(255,153,0.9));
background-origin: border-Box;
background-clip: content-Box,border-Box;
background-image: linear-gradient(to bottom,#ffffff,#ffffff),linear-gradient(to top,0.9));
}
<a role="button" class="apply-button" href="#"><p>apply</p></a>
解决方法
试图理解你的问题,但没有得到你真正想要的:
这是实现悬停效果的示例代码。
package CrudCinema;
import java.net.URL;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDate;
import java.util.Optional;
import java.util.ResourceBundle;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonType;
import javafx.scene.control.DatePicker;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
/**
*
* @author kenza ben debba
*/
public class MainController implements Initializable {
@FXML
private TextField tfId;
@FXML
private TextField tfNom;
@FXML
private TextField tfNB_Salles;
@FXML
private TextField tfNB_Places;
@FXML
private DatePicker tfDate_Diffusion;
@FXML
private TableView<Cinema> tvCinema;
@FXML
private TableColumn<Cinema,Integer> colId;
@FXML
private TableColumn<Cinema,String> colNom;
@FXML
private TableColumn<Cinema,Integer> colNB_Salles;
@FXML
private TableColumn<Cinema,Integer> colNB_Places;
@FXML
private TableColumn<Cinema,String> colDate_Diffusion;
@FXML
private Button btnAjouter;
@FXML
private Button btnModifier;
@FXML
private Button btnSupprimer;
@FXML
private void handleButtonAction(ActionEvent event) {
if(event.getSource() == btnAjouter){
insertRecord();
}else if (event.getSource()== btnModifier){
updateRecord();
}else if (event.getSource()== btnSupprimer){
deleteButton();
}
}
@Override
public void initialize(URL url,ResourceBundle rb) {
showCinema() ;
}
public Connection getConnection(){
Connection conn;
try{
conn= DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb","root","");
return conn;
}catch(SQLException ex) {
System.out.println("Error:" + ex.getMessage());
return null;
}
}
public ObservableList<Cinema> getCinemaList(){
ObservableList<Cinema> cinemaList= FXCollections.observableArrayList();
Connection conn = getConnection();
String query = "SELECT * FROM cinema";
Statement st;
ResultSet rs;
try {
st = conn.createStatement();
rs = st.executeQuery(query);
Cinema cinema;
while (rs.next()){
cinema= new Cinema(rs.getInt("Id"),rs.getString("Nom"),rs.getInt("NB_Salles"),rs.getInt("NB_Places"),rs.getString("Date_Diffusion"));
cinemaList.add(cinema);
}
}catch (SQLException ex) {
ex.printStackTrace();
}
return cinemaList;
}
public void showCinema(){
ObservableList<Cinema> list = getCinemaList();
colId.setCellValueFactory(new PropertyValueFactory <>("Id"));
colNom.setCellValueFactory(new PropertyValueFactory <>("Nom"));
colNB_Salles.setCellValueFactory(new PropertyValueFactory <>("NB_Salles"));
colNB_Places.setCellValueFactory(new PropertyValueFactory <>("NB_Places"));
colDate_Diffusion.setCellValueFactory(new PropertyValueFactory <>("Date_Diffusion"));
tvCinema.setItems(list);
}
@FXML
private void showDate(ActionEvent event) {
LocalDate ld= tfDate_Diffusion.getValue();
}
private void insertRecord(){
String query = "INSERT INTO cinema VALUES (" + tfId.getText() + ",'" + tfNom.getText() + "','" + tfNB_Salles.getText() + "',"
+ tfNB_Places.getText() + "," + tfDate_Diffusion.getValue() + ")";
executeQuery(query);
showCinema();
// String query = "insert into cinema(Id,Nom,NB_Salles,NB_Places,Date_Diffusion)values(&id,'&Nom',&NB_Salles,&NB_Places,TO_DATE('&Date_Diffusion','YYYY/MM/DD'));";
}
private void updateRecord(){
String query = "UPDATE cinema SET Nom = '" + tfNom.getText() + "',NB_Salles = '" + tfNB_Salles.getText() + "',NB_Places = " +
tfNB_Places.getText() + ",Date_Diffusion = " + tfDate_Diffusion.getValue() + " WHERE Id = " + tfId.getText() + "";
executeQuery(query);
showCinema();
}
private void deleteButton(){
Alert alert = new Alert( Alert.AlertType.CONFIRMATION) ;
alert.setTitle("Confirmation de supprission !!");
alert.setHeaderText(null);
alert.setContentText("Voulez-vous vraiment supprimer ");
Optional<ButtonType> action = alert.showAndWait();
if ( action.get() == ButtonType.OK) {
String query = "DELETE FROM cinema WHERE Id =" + tfId.getText() + "";
executeQuery(query);
showCinema();
}
}
private void executeQuery(String query) {
Connection conn = getConnection();
Statement st;
try{
st = conn.createStatement();
st.executeUpdate(query);
}catch(SQLException ex){
ex.printStackTrace();
}
}
}
.showOnHover{display : none;}
.apply-button:hover .showOnHover{
display : inline;
}
.apply-button:hover{
display:block;
text-align : center;
}
.apply-button {
display : inline-block;
margin-top: 8rem;
border-radius: 5em;
box-shadow: 0 8px 4px 0 rgba(0,0.25);
border-style: solid;
border-width: 0.275rem;
border-image-slice: 0;
border-image-source: linear-gradient(to top,#0270bb,#c6e357,rgba(255,153,0.9));
background-origin: border-box;
background-clip: content-box,border-box;
background-image: linear-gradient(to bottom,#ffffff,#ffffff),linear-gradient(to top,0.9));
}