【问题标题】:How to show the HOVER attribute on IE11如何在 IE11 上显示 HOVER 属性
【发布时间】:2019-06-12 10:57:11
【问题描述】:

我在表格上设置:hover 属性以更改悬停时的行颜色。它在 CHROME 和 EDGE 上运行良好,但在 IE 11 上运行良好。

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>

<meta http-equiv='X-UA-Compatible' content='IE=9; IE=10; IE=11;IE=8; IE=7; IE=EDGE'/>

CSS 部分:

tr.fullrow:hover{
    background:yellow;
    font-size:16px;
}

HTML 部分:

<table border = "1" class ="tablewip">
    <caption> Assy WIP by Product </caption>
      <thead>
         <tr class ="headerrow">
         <td class="headercells" font-size:100px;  nowrap >'.$colHeader.'</td>
         </tr>
      </thead>
      <tbody>
         <tr class = "fullrow">
            <td  class = "wipcells" nowrap >Text </td>
         </tr>
      </tbody>
</table>

堆栈sn-p

<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01//EN' 'http://www.w3.org/TR/html4/strict.dtd'>
<html>
<head>
  <meta http-equiv='X-UA-Compatible' content='IE=9; IE=10; IE=11;IE=8; IE=7; IE=EDGE' />
  <style>
    tr.fullrow:hover {
      background: yellow;
      font-size: 16px;
    }
  </style>
</head>

<body>
  <table border="1" class="tablewip">
    <caption> Assy WIP by Product </caption>
    <thead>
      <tr class="headerrow">
        <td class="headercells" font-size:100px; nowrap>'.$colHeader.'</td>
      </tr>
    </thead>
    <tbody>
      <tr class="fullrow">
        <td class="wipcells" nowrap>Text </td>
      </tr>
    </tbody>
  </table>
</body>
</html>

【问题讨论】:

  • 悬停效果很好。但是,您的标记无效。注意内联样式应该放在style 属性中,nowrap 应该是white-space: nowrap;

标签: html css


【解决方案1】:

我会为悬停元素设置 td 的样式,而不是 tr。例如:

tr.fullrow:hover td{
    background:yellow;
    font-size:16px;
}

【讨论】:

  • OP 询问如何设置tr 的样式,而不是设置样式,顺便说一句,这可能是tr 的任何后代,因此使这个答案无关紧要,因为它没有回答问题问。
【解决方案2】:

对于 CSS 部分,请尝试以下操作:

tr.fullrow:hover{
    background-color:yellow;
    font-size:16px;
}

请参阅此示例:https://codepen.io/pjamourik/pen/EGBgEy

【讨论】:

  • 因为background:yellow;,即简写版本,与长版本background-color:yellow; 一样好用,这并不能回答问题。
  • 简写版本用于在单个属性中指定所有背景属性;如果您只需要指定颜色属性,请使用背景颜色。
  • 由于速记版本可以在一行中定位一个或多个背景属性(并且经常这样做,以确保覆盖任何以前的设置),您的答案并不能解决所提出的问题.
猜你喜欢
  • 2014-11-22
  • 2013-04-06
  • 1970-01-01
  • 2015-02-17
  • 2015-08-06
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多