html - 在前后插入一些文本

标签 html css

我需要在 hey 字符前后插入一些文本。 我需要一个纯 CSS 解决方案。

我的 html:

<span class="wsite-headline">
     <font size="5">hey</font>
     <br>
     <strong>dude</strong>
</span>

我已经尝试过这个 css:

.wsite-headline font:before { content "before";  }
.wsite-headline font:after { content "after";  }

但它不起作用。

有什么想法吗?

最佳答案

::对于选择器,您缺少一个 :content 之后

.wsite-headline font::before { content: "before";  }

(<font> 在 HTML5 中被弃用,考虑使用 <span> 和 CSS 来定义大小)

关于html - 在前后插入一些文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34814037/

相关文章:

html - 将悬停更改为 CSS 到 OnClick

html - 垂直对齐 : top two floated divs within container

html - 如何让我的表格滚动,而背景在 html/css 中保持固定?

css - Nuxt 3 + SASS : Can't use include paths with @import and @use

html - 在 div 中居中行内 block 元素

jquery - CSS - 根据包含的文本宽度更改 DIV 宽度

java - Java 使用什么版本的 HTML 来呈现标记文本

javascript - 类似 Facebook 的 anchor 滚动

Javascript 在特定类出现后在 div 中包装多个 p 标签

javascript - 同时运行两个独立的 jQuery