css - 单击时选择整个 <td> 而不是仅选择其中的 <a>

标签 css twitter-bootstrap sass

好的,事情是这样的,我有一张 table ,里面有一些 <a>的,我想要的是:使完整的 <td> 可点击其中包含那些 <a>的。

粘贴我的代码会更好地解释我想要什么

<td>
  <a><span>{{:: row.spread.spread}} ({{:: row.spread.moneyLine}})</span></a>
</td>

目前唯一可点击的区域是带有红色边框的区域

enter image description here

这是我的CSS

  td {
    border-bottom: 0;
    font-weight: bold;
    padding: get-space(x-small) + 2;
    text-align: center;
    vertical-align: middle;

    a {
      border: 1px solid red;
    }

好吧,我只需要采取完整的方法 td并使它们可点击,而不是只能点击链接,你们清楚吗?

最佳答案

指定 displayblock在你的 <a>元素,然后添加填充。删除 <td> 上的填充也可能是值得的元素:

td {
    border-bottom: 0;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    padding: 0;

    a {
      padding: get-space(x-small) + 2;
      display: block;
    }
}

如果需要保留红色边框,定位<span>元素:

td {
    border-bottom: 0;
    font-weight: bold;
    text-align: center;
    vertical-align: middle;
    padding: 0;

    a {
      padding: get-space(x-small) + 2;
      display: block;

      span {
        border: 1px solid red;
      }
    }
}

关于css - 单击时选择整个 <td> 而不是仅选择其中的 <a>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28752562/

相关文章:

sass - 基础全局样式在 Grunt 文件中意外重复

HTML 选择下拉选项 Z-index

css - 响应式输入文字大小

jquery - bootstrap popover 中的 html 表单不起作用

css - 使用断点在 Sass 中使用 Mixin 或 Placeholder

html - Sass 编译并对更改的内容创建注释

javascript - 在键入下一个跨度项之前,javascript 创建新行的键入效果

css - 使用词缀 Bootstrap 后如何从顶部开始隐藏 100px

html - 字体图标后垂直对齐文本

javascript - 使用 fullPage.js 时无法单击 Bootstrap 模式对话框