悬停时颜色和背景颜色不会改变

时间:2021-07-21 09:47:38

标签: css hover

我有一个带有图像、标题和段落的 div 块。当我将鼠标悬停在该 div 上时,我想更改该 div 的背景颜色和文本颜色,但仅更改背景颜色,颜色标签被简单地忽略。我该如何解决这个问题?

.Div_Systemingenieur {
  width: 18%;
  padding: 20px;
  border: 1px;
  border-color: white;
  border-radius: 25px;
  float: left;
  margin-left: 70px;
  margin-top: 70px;
  background-color: white;
  transition: 0.5s;
  background-color: white;
  color: #24252a;
 }

.Systemingenieur_Text {
 text-align: center;
 border: 1px;
 border-color: white;
 border-style: solid;
 border-radius: 25px;
 padding-bottom: 10%;
 color: #24252a;
}

.Heading_Systemingenieur {
 margin-bottom: 20px;
 margin-left: 15px;
 margin-top: 10px;
}
 .Div_Systemingenieur:hover {
   background-color: #24252a;
   color: white;
}

注意:我对使用 css 编程还是很陌生,我正在为一个学校项目做这件事。 PS:有些名字是用德语写的,因为它是我的母语。 好好休息一天吧! 吕西安

1 个答案:

答案 0 :(得分:0)

.Div_Systemingenieur {
  width: 18%;
  padding: 20px;
  border: 1px;
  border-color: white;
  border-radius: 25px;
  float: left;
  margin-left: 70px;
  margin-top: 70px;
  background-color: white;
  transition: 0.5s;
  background-color: white;
  color: #24252a;
 }

.Systemingenieur_Text {
 text-align: center;
 border: 1px;
 border-color: white;
 border-style: solid;
 border-radius: 25px;
 padding-bottom: 10%;
}

.Heading_Systemingenieur {
 margin-bottom: 20px;
 margin-left: 15px;
 margin-top: 10px;
}
 .Div_Systemingenieur:hover {
   background-color: #24252a;
   color: white;
}