css - 我无法获取::after 以在表格中显示内容

标签 css css-selectors pseudo-element

我尝试使用::before 和::after 将文本放在括号中的特定表格单元格中。单元格内容本身是从高级自定义字段表单中提取的,理论上会插入括号之间。

我有以下CSS

#ingredients td:nth-child(4)::before {content:"(";}
#ingredients td:nth-child(4)::after {content:")";}

左括号正常显示,但我无法显示右括号。我做错了什么?

最佳答案

您的代码,在这里工作正常...

#ingredients td:nth-child(4)::before {
  content: "(";
}

#ingredients td:nth-child(4)::after {
  content: ")";
}
<table id="ingredients">
  <tr>
    <td>blahblah</td>
    <td>blahblah</td>
    <td>blahblah</td>
    <td>blahblah</td>
  </tr>
</table>

关于css - 我无法获取::after 以在表格中显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44861418/

相关文章:

css - 如何将图像添加到自定义复选框的背面

html - 使用 CSS,使菜单按钮可点击

css - 使用第 nth-child 还是在 CSS 中创建新类?

javascript - 如何使用全局选择器响应除一个元素之外的所有点击事件?

css - 无法在 div 后正确附加伪元素

html - 在父 DIV 中垂直居中 CSS::after Content,带 float

html - 是否可以并排设置两个 div,而一个 div 在屏幕之外而不使用 display none 或 width zero?

html - 如何将此破折号伪元素放在 li 之间

html - 为什么这种风格不继承呢?

css - 第 n 个 child 及之前