【问题标题】:How to change one element style when another is hovered [closed]当另一种元素悬停时如何更改一种元素样式[关闭]
【发布时间】:2022-06-16 16:31:17
【问题描述】:

抱歉上次弄不清楚了,真的是代码转储,因为我不知道如何解释发生了什么。好消息,我现在修好了。但是现在我遇到了 CSS 的问题。当悬停在按钮上时,我试图更改表格行 () 的背景颜色(我的代码不起作用)。下面提供了css。问题出在 CSS 的底部(两种悬停样式):请告诉我我做错了什么,我搜索了这么久的答案但是我没有想出一个合适的解决方案。

body{
    margin: 0px;
    font-family: Helvetica;
}
header{
    background-color: #e7e7e7;
    height: 100px;
    padding-top: 25px;
    text-align: center;
    font-size: 50px;
}
table{
    background-color: white;
    border-collapse: collapse;
    font-size: 20px;
    margin-left: auto;
    margin-right: auto;
}
#myTable{
    margin-top: 50px;
}
th,td{
    padding: 20px;
    text-align: center;
    border:1px solid black;
    width: 200px;
    height: auto;
}
.nthChild{
    background-color: #e7e7e7;
}
#nlRow th{
    border-top: 0px;
}
input{
    font-size: 20px;
    width: 100%;
    padding: 5px 0px;
    border-radius: 4px;
}
#numeracyCredits, #literacyCredits{
    width: 30%;
}
.button{
    font-size: 20px;
    padding: 5px 20px;
    width: 15%;
    border-radius: 4px;
    background-color: white;
    color: black;
    border: 2px solid black;
    transition-duration: 0.3s;
}
.button:hover{
    background-color: #c4c2c2;
    transition-duration: 0.3s;
}
.button:hover + .nthChild{
    background-color: white;
}

【问题讨论】:

  • 此问题似乎不包含实际问题...编辑:查看您的个人资料,您似乎只是将代码转储作为问题发布,这永远不会为您提供有用的答案。请花点时间阅读How do I ask a good question?
  • 什么警报不起作用?是isNaN(availableCredits && passedCredits && failedCredits)的错误检查吗?

标签: css


猜你喜欢
  • 2011-10-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-30
  • 1970-01-01
  • 1970-01-01
  • 2012-09-07
相关资源
最近更新 更多