html - CSS 鼠标悬停高亮表格超链接

标签 html css mouseevent highlight mouseover

我正在使用 CSS3 hover 效果并面临一个元素的问题。

问题是当我将鼠标指向第一个 时(使用 hover),th 超链接的颜色与背景,所以我需要在那个事件上改变它。

这里是一个活生生的例子:

.maps-btn tr {
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
.maps-btn tr:hover {
    background-color: blue;
    color: white;
}
.maps-btn a:hover {
    color: white;
}
<div class="col-md-9">
    <div class="row">
        <table class="table table-bordered table_class maps-btn">
            <thead>
                <tr>
                    <th>1111</th>
                    <th>2222</th>
                    <th>3333</th>
                    <th>4444</th>
                    <th>5555</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><a href="#">AAAA</a></td>
                    <td>BBBB</td>
                    <td>CCCC</td>
                    <td>DDDD</td>
                    <td>EEEE</td>
                </tr>
                <tr>
                    <td><a href="#">FFFF</a></td>
                    <td>GGGG</td>
                    <td>HHHH</td>
                    <td>IIII</td>
                    <td>JJJJ</td>
                </tr>
            </tbody>
        </table>
    </div> 
</div>

我想禁用 hover on thead。我想在 tbody 上使用悬停。

最佳答案

你可以这样做:

.maps-btn tr {
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
.maps-btn a {
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
.maps-btn tr:hover {
    background-color: blue;
    color: white;
}

.maps-btn tr:hover a {
    background-color: blue;
    color: white;
}
.maps-btn a:hover  {
    color: white;
}
<div class="col-md-9">
    <div class="row">
        <table class="table table-bordered table_class maps-btn">
            <thead>
                <tr>
                    <th>1111</th>
                    <th>2222</th>
                    <th>3333</th>
                    <th>4444</th>
                    <th>5555</th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td><a href="#">AAAA</a></td>
                    <td>BBBB</td>
                    <td>CCCC</td>
                    <td>DDDD</td>
                    <td>EEEE</td>
                </tr>
                <tr>
                    <td><a href="#">FFFF</a></td>
                    <td>GGGG</td>
                    <td>HHHH</td>
                    <td>IIII</td>
                    <td>JJJJ</td>
                </tr>
            </tbody>
        </table>
    </div> 
</div>

关于html - CSS 鼠标悬停高亮表格超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45542755/

相关文章:

html - Bootstrap 4 和用户详细信息 - 如何做 "bootstrap"或正确的方法?

iphone - 有谁知道我在哪里可以找到 iPhone 搜索栏样式?

Eclipse 文本编辑器调整大小

java - 使用向上/向下键导航后,jTable 的行号错误

html - 两个 div 并排并清除第三个 div 的 flex

javascript - 如何将列表项与数组中的值匹配

javascript - 移除 'spaces' d元素占用的 "display:none"

php - 在 php 中将 html 转换为 pdf?

html - CSS 在带有页脚的页面上的菜单中滑动?

css - 单击 div 到底层元素