【问题标题】:How to make ::before/::after element clickable in css?如何在css中使::before/::after元素可点击?
【发布时间】:2019-12-14 02:11:14
【问题描述】:

我尝试使用 ::after 将 box-shadow 添加到表中的行,因为在 Internet Explorer 中,表中的 box-shadow 存在许多错误,所以这是我在阴影显示正常时的一种解决方案。我有行中的数据,它必须是可点击的,并且应该可以选择文本。

SCSS:

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 3px;
    padding: 0 2px;
    border-radius: 30px;

    &-row {
        position: relative;
        transition: all 0.2s ease;
        border: 1px solid $c-white;
        border-radius: 3px;
        background-color: $c-white;
        box-shadow: 0 1px 7px 10px red;

        &::after {
            content: '';
            position: absolute;
            display: block;
            border-radius: 3px;
            width: 100%;
            height: 48px;
            box-shadow: 0 1px 7px 0 rgba(0, 0, 0, 0.12);
            left: 0;
          }

    }
}

HTML:

<table mat-table [dataSource]="source">
  <ng-container matColumnDef="select">
    <th mat-header-cell *matHeaderCellDef class="table-header-cell"></th>
    <td mat-cell *matCellDef="let row" class="table-cell button"></td>
  </ng-container>
</table>

我尝试了z-index:,但没有结果。

有什么方法可以让我的行可点击,以便我可以从中选择文本??

【问题讨论】:

  • 只为前后添加宽度和高度。请提供有价值的代码
  • 你能再描述一下吗?
  • 你能把对应的html发布到你的css吗?目前您的 HTML 中没有 table-row
  • 正如您在&lt;td&gt; 中看到的那样,*matCellDef=let row 中有,所以我认为这是table-row

标签: html css angular pseudo-class


【解决方案1】:

试试这个

css

.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 3px;
    padding: 0 2px;
    border-radius: 30px;

    &-row {
        position: relative;
        transition: all 0.2s ease;
        border: 1px solid $c-white;
        border-radius: 3px;
        background-color: $c-white;
        box-shadow: 0 1px 7px 10px red;

        &::after {
            content: '';
            position: absolute;
            display: block;
            border-radius: 3px;
            width: 48px;
            height: 48px;
            box-shadow: 0 1px 7px 0 rgba(0, 0, 0, 0.12);
            left: 0;
            z-index:999;
          }

    }
}

【讨论】:

  • 请分享任何小提琴来检查你的输出老兄
  • 我不明白你的意思fiddle,如果你能解释一下
  • 请在这里分享你的代码,我需要看到你的输出jsfiddle.net
猜你喜欢
  • 1970-01-01
  • 2020-09-20
  • 1970-01-01
  • 2015-05-06
  • 2011-06-22
  • 2019-10-01
  • 2012-12-17
  • 2023-02-21
相关资源
最近更新 更多