【问题标题】:Is there any reason why the pseudoelements ::after and ::before don't work in Foundation?伪元素 ::after 和 ::before 在 Foundation 中不起作用有什么原因吗?
【发布时间】:2019-08-30 14:39:08
【问题描述】:

我正在使用 Foundation 6 for Sites 创建响应式网站。 我没有使用伪元素 ::after 和 ::before (我没有忘记 content 属性)。 我的浏览器代码检查器没有显示伪元素,并且它们没有在页面上实现。

任何想法为什么会发生以及如何处理它? sass 会不会有问题?

【问题讨论】:

  • 您好,请提供不起作用的代码。它在这里对我有用:codepen.io/DanielRuf/pen/xegbaQ
  • 这里是 --> p::after { content: "";位置:绝对;宽度:0;高度:0;左:rem-calc(-24);顶部:rem-calc(33);边框:rem-calc(2.5) 实心;边框颜色:透明 $body-background 透明透明; }
  • 天哪!有用!非常感谢mucn。

标签: sass zurb-foundation pseudo-element zurb-foundation-6


【解决方案1】:

我一直在使用它们:)

您说您确保在 psuedo 元素中包含 content: '' 属性,这很好。

如果组件是 Foundation CSS 组件并且该元素已经使用了伪元素,您可以使用浏览器的检查器找到它并查看 CSS 的目标是什么。

例子:

.notification-reward {
  align-items: baseline;
  animation: jellyIn 1s;
  display: flex;
  position: absolute;
  right: 0;
  top: -58%;

  &::after {
    color: $primary-light;
    content: attr(data-earned-points);
    font-size: $stat-font-size;
    font-weight: 700;
    left: 4.3625rem;
    position: absolute;
    top: 6%;
  }

  &::before {
    color: $primary-light;
    content: '+';
    font-size: rem-calc(44);
    font-weight: 700;
    left: rem-calc(40);
    position: relative;
    top: -1.6525rem;
  }
}

【讨论】:

  • 谢谢。我记得内容,但忘记了&。我的大错。
猜你喜欢
  • 2021-11-03
  • 1970-01-01
  • 2015-01-04
  • 1970-01-01
  • 1970-01-01
  • 2011-11-15
  • 1970-01-01
  • 2012-05-21
相关资源
最近更新 更多