html - 如何突出显示表格中的选定行?

标签 html css hover

这是我的表格..我应该添加什么来让选定的行突出显示? 这样可以更清楚地看到我的鼠标在哪里...................................... .....................

<style type ="text/css">
      table.imagetable {
          font-family: verdana,arial,sans-serif;
          font-size:15px;
          color:#333333;
          border-width: 1px;
          border-color: #999999;
          border-collapse: collapse;
          width:100%;
      }
      table.imagetable th {
          background:#b5cfd2 url('/static/cell-blue.jpg');
          border-width: 1px;
          padding: 12px;
          border-style: solid;
          border-color: #999999;
      }
      table.imagetable td {
          background:#dcddc0 url('/static/cell-grey.jpg');
          border-width: 1px;
          padding: 8px;
          border-style: solid;
          border-color: #999999;
      }
    </style>

    <table class="imagetable">
      <tr>
        <th>Time</th><th>Category</th><th>Filename</th>
      </tr>
        {% for (t,f,c,l, t2) in data %}
          <tr>
              <td style = "padding:3px;">{{date}} {{t2}}</td>
              <td sytle = "padding:3px;"><a href = "/report_category/{{c}}/">{{c}}</a></td>
              <!-- l is the relative location, we need absolute directory here.-->
              <td style = "padding:3px;"><a href = "/{{l}}">{{f}}</a></td>
           </tr>
        {% endfor %}
    </table>

最佳答案

css 文件中使用 :hover 属性(根据需要更改颜色):

table.imagetable tr:hover {
    background-color: #EBECCD;
}

table.imagetable tr {
    background-color: #dcddc0;
}

table.imagetable td {
    background:#dcddc0 url('/static/cell-grey.jpg'); // remove this line
    padding: 3px;
}

table.imagetable {
    width: 100%;
}

像这样清除你的模板:

<table class="imagetable">
  <thead>
    <tr>
      <th>Time</th><th>Category</th><th>Filename</th>
    </tr>
  </thead> 
  <tbody>
  {% for (t,f,c,l, t2) in data %}
    <tr>
      <td>{{date}} {{t2}}</td>
      <td><a href = "/report_category/{{c}}/">{{c}}</a></td>
      <td><a href = "/{{l}}">{{f}}</a></td>
     </tr>
  {% endfor %}
  </tbody>
</table>

关于html - 如何突出显示表格中的选定行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34812854/

相关文章:

javascript - Jquery fileupload 没有给我正确的路径

html - 数据加载时的水平加载器

html - 阻止页面出现在浏览器历史记录中

javascript - Uncaught ReferenceError : Tankvalue is not defined

html - 网站重新加载时出现子菜单

html - 下拉样式在 ff 和 IE 中无法正确呈现

javascript - 在 css 中使用 `rotate()` 使聊天消息在聊天应用程序中向上增长?

CSS 导航栏悬停 - 背景更改

jquery - Target 与多个元素具有相同类名的单个元素

css - 选择器无法从 Chrome 正确转换为 Firefox 和 Safari