【问题标题】:Insert anchor link in :after selector content在 :after 选择器内容后插入锚链接
【发布时间】:2014-06-27 16:41:11
【问题描述】:

所以我只是想在一些内容之后插入一个链接,但它只显示文字字符串。我该如何更改?

<p>Blah Blah Blah I'm some content</p>

CSS:

p:after {
    content: '- <a href="http://www.stackoverflow.com">Learn More</a>'
}

当然会产生文本:

<!-- language: lang-none -->

Blah Blah Blah I'm some content - <a href="http://www.stackoverflow.com">Learn More</a>

我希望得到以下输出

Blah Blah Blah 我很满足 - Learn More

【问题讨论】:

标签: css html css-selectors


【解决方案1】:

这类事情你需要 javaScript。

使用 jQuery 可以轻松完成。 DEMO

HTML

<p id="p">Blah Blah Blah I'm some content</p>

jQuery

var plink ='- <a href="http://www.stackoverflow.com">Learn More</a>';
$('#p').append(plink);

【讨论】:

    猜你喜欢
    • 2020-02-07
    • 1970-01-01
    • 2013-08-19
    • 1970-01-01
    • 1970-01-01
    • 2011-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多