- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我有以下 fiddle .
编辑:应用行边框样式:
table,th,td
{
border:2px solid black;
border-collapse:collapse;
}
tr:hover td
{
background-color:grey;
border-top: 2px solid rgb(10, 0, 255);
border-bottom: 2px solid rgb(10, 0, 255);
}
td:hover
{
background-color:rgb(214,214,214) !important;
border:2px solid red !important;
border-top: 2px solid red;
border-bottom: 2px solid red;
}
我要突出显示 ROW 和 CELL。本来想做点十字线,但是列背景着色需要JavaScript,我暂时不做。
在此希望 ROW:hover
背景颜色变暗并强调边框。
然后 td:hover
变成不同的颜色,并且边框强调不同。
在 Chrome 中检查,而不是在 Firefox 中检查。
问题:需要使用!important
。单元格左边框和顶部未着色为红色?
那么有没有一种方法可以不使用 important!
来编写 CSS,并在 TD 单元格上正确设置边框样式?
最佳答案
您只需使用 CSS(无需 Javascript)即可完成您最初的十字准线创意。使用 ::before
和 ::after
用于突出显示的伪元素。使用此方法时 Firefox 存在一个小问题,因此我为此编写了一个修复程序。
border-collapse: collapse
在 <tds>
上建立边界以奇怪的方式行事。相反,将边框放在 <trs>
上和 <cols>
. border-collapse: collapse
也切掉边缘。为了解决这个问题,您必须发挥创意并在所有外部绘制额外的边框 <tds>
和 <ths>
.更奇怪的是,它“吃掉”了顶部的一个像素和底部的两个像素。所以你需要 3px
在顶部获得 2px
边框,和 4px
在底部得到一个2px
边框。
table {
border-collapse: collapse;
overflow: hidden;
z-index: 1;
}
td, th, .row, .col, .ff-fix {
cursor: pointer;
padding: 10px;
position: relative;
}
tr:last-child td {
border-bottom: 4px solid black;
}
tr, col {
border: 2px solid black;
}
th {
border-top: 3px solid black;
}
th:last-child, td:nth-child(3n) {
border-right: 4px solid black;
}
td:first-child, th:first-child {
border-left: 3px solid black;
}
td:hover {
border: 2px solid red;
}
td:hover:first-child {
border-left: 3px solid red;
}
td:hover:nth-child(3n) {
border-right: 4px solid red;
}
tr:last-child td:hover {
border-bottom: 4px solid red;
}
td:hover::before,
.row:hover::before,
.ff-fix:hover::before {
background-color: #ffa;
content: '\00a0';
height: 100%;
left: -5000px;
position: absolute;
top: 0;
width: 10000px;
z-index: -1;
}
td:hover::after,
.col:hover::after,
.ff-fix:hover::after {
background-color: #ffa;
content: '\00a0';
height: 10000px;
left: 0;
position: absolute;
top: -5000px;
width: 100%;
z-index: -1;
}
HTML:
<table>
<col /><col /><col />
<tr>
<th class="col">First Name</th>
<th class="col">Middle Name</th>
<th class="col">Last Name</th>
</tr>
<tr>
<td>Peter</td>
<td>Jeffery</td>
<td>Griffin</td>
</tr>
<tr>
<td>Lois</td>
<td>Marie</td>
<td>Griffin</td>
</tr>
<tr>
<td>Margie</td>
<td>Ann</td>
<td>Thatcher</td>
</tr>
</table>
function firefoxFix() {
if ( /firefox/.test( window.navigator.userAgent.toLowerCase() ) ) {
var tds = document.getElementsByTagName( 'td' ),
ths = document.getElementsByTagName( 'th' );
for( var index = 0; index < tds.length; index++ ) {
tds[index].innerHTML = '<div class="ff-fix">' + tds[index].innerHTML + '</div>';
};
for( var index = 0; index < ths.length; index++ ) {
ths[index].innerHTML =
'<div class="' + ths[index].className + '">'
+ ths[index].innerHTML
+ '</div>';
ths[index].className = '';
};
var style = '<style>'
+ 'td, th { padding: 0 !important; }'
+ 'td:hover::before, td:hover::after { background-color: transparent !important; }'
+ '</style>';
document.head.insertAdjacentHTML( 'beforeEnd', style );
};
};
firefoxFix();
关于CSS 表格 tr 悬停一种颜色/边框和 td 悬停另一种颜色/边框而不重要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15269921/
我正在学习和使用 jQuery,并且想要显示某些元素的删除图标。 我有一个外部主 div,其中包含许多元素的包装器。在元素包装器内部,我想当用户将鼠标悬停在元素包装器上时显示删除图标,并在用户移出元素
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我从 Qt 开始,每当有人将鼠标悬停在 QPushButton 上时,我想将 QPushButton 设置为不同的图标。到目前为止,这是我的代码: #include QPushButton *but
我从 Qt 开始,我想在有人将鼠标悬停在 QPushButton 上时将其设置为不同的图标。到目前为止,这是我的代码: #include QPushButton *button = new QPus
我有以下代码... jQuery(function($) { var timer; $('.action-viewer').hide(); $('.task').on('mouseover
我有一张照片,当用户将鼠标悬停在它上面时,我会在照片顶部显示(使用绝对定位)2 个箭头,一个用于进入上一张照片,一个用于进入下一张照片。这是到目前为止的代码... $('a.large_product
$('li > a').hover( function(){ $(this).animate({ backgroundColor: '#2a639a', color: '#fff'
我有一个悬停事件附加到几个链接,当您点击它时,会出现一个框。 有没有一种方法可以让悬停事件仅在鼠标悬停在链接上超过 500 毫秒时触发?因此,目前只要鼠标移到链接上,就会出现该框,但我希望只有当鼠标悬
我正在创建包含各种样式控件的演示应用程序。它允许我快速预览更改。 我的问题是下面的代码不起作用: Pressed button 它表示 IsPressed 的 setter 受到保护。我明白了,但我需
我正在尝试使用 js 并创建带有一些“信息文本”的“描述框” HTML google JS function info() {} 我不知道是哪个代码用一些文本创建了所谓的“描
我有一个 Accordion 风格的菜单,在悬停状态下工作正常,但我想改为点击... $(document).ready(function(){ $('#nav > li').hover(
我正在使用 Chartjs v.1.0.2 并尝试将点设置为仅在悬停在当前点上时出现。同样的问题是当我使用悬停或鼠标悬停时。可以使用 getPointsAtEvent(e); 找到当前点,但它仅在我将
我使用foreach 语句访问IEnumerable 的所有元素并将其呈现在详细信息页面中。我想让每个元素的悬停属性只影响一个元素。所以我使用 jQuery 单独影响每个元素 但是当我运行代码并将鼠标
首先提前感谢您的帮助。 案例:我在一行中有多个 div。这些 div 位于一个框中,我可以在此框中水平滚动以查看其他 div。我制作了两个按钮(L 表示左侧,R 表示右侧),以便在悬停或单击这些按钮时
我正在创建一个应用外观页面。 我希望在鼠标悬停时打开底部菜单上的其中一个按钮。 这感觉像是一项简单的任务,但我所做的一切似乎都不起作用。我错过了什么,我做了很多研究,但似乎找不到解决方案。 我尝试使用
我遇到的问题是,当您将鼠标悬停在按钮上时,只有按钮的某些部分会触发悬停/可点击状态,而不是所有实际 block 。有什么想法吗? 这是使用它的站点:http://www.revival.tv/turn
我有一位客户想要在他们的网站上实现特定功能,但我有点困惑如何做到这一点。 基本上,如果你查看他们的 existing site您可以看到 4 个圆形按钮。 他们想要的是,当有人将鼠标悬停(或单击,如果
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 关闭 9 年前。 关于您编写的代码问题的问题必须在问题本身中描述具体问题 — 并且包括有效代码 以
我目前正在编写我的第一个响应式网站(总的来说我是一个初学者)并且我遇到了很多障碍。其中之一是我的菜单有问题。我会尽量具体。我有一个用于桌面的水平菜单和一个用于平板电脑/手机的垂直菜单。我不知道如何解决
我正在为网站创建菜单。我正试图在链接上实现悬停 和点击 效果。我希望列表元素 a 上的悬停事件触发彩色动画并添加“事件”类。如果触发了点击和悬停事件,我想为该元素分配相同的类。问题是,一旦元素未悬停并
我是一名优秀的程序员,十分优秀!