html – 如何在元素外部显示:after

前端之家收集整理的这篇文章主要介绍了html – 如何在元素外部显示:after前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在下面的例子中,我怎样才能使得:after生成的文本超出了span的框? (它目前在内部渲染,即它使span元素更宽)

HTML

@H_301_4@<span class="my">Boxtext</span>

CSS

@H_301_4@span.my { padding: 4px 8px; background-color: red; display: inline-block; border-radius: 10px; margin-left: 20px; } span.my:after { content: " text that is supposed to come after the Box"; }

我猜这有点类似于list-style-position,你可以在里面或外面选择……

解决方法

我相信CSS内容被认为是呈现它的对象的一部分.您可以创建以下参数:after应该被命名为:append.

对于您的情况,您可以尝试在span.my中添加一个额外的元素:

@H_301_4@<span class="my"><span>Boxtext</span></span> span.my span { ... } span.my:after { ... }

或具体设计内容样式.

@H_301_4@span.my:after { content: " text that is supposed to come after the Box"; background-color: white; position: absolute; margin-left: 10px; }

猜你在找的HTML相关文章