html - 使用 :before in CSS-formatted links 时避免换行

标签 html css line-breaks

我在 CSS 中使用 :before 将图像添加到我网站上的某些链接

a.ext:before {
    content:            url(./_img/ext.png);
}

不幸的是,如果空间不大,图像和文本会分开。

with line breaks 对比 without line breaks

如果图像绑定(bind)到链接中的第一个单词(在 HTML 中,我会为此使用  ),那就太好了。 CSS 中是否有类似的东西?

编辑: Screenshot of JSFiddle

最佳答案

如果我理解您的问题,您是在尝试在元素宽度不足以容纳图像时不让图像环绕在文本下方。

overflow 和 white-space:nowrap 的组合可能会得到您正在寻找的结果。

关于html - 使用 :before in CSS-formatted links 时避免换行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14869609/

相关文章:

javascript - 使用 JavaScript 编写拖放代码时出现 "Argument 1 of Node.appendChild is not an object."

html - 带有固定标题和 2 个侧边栏的 Bootstrap

html - 悬停在下拉菜单中不起作用?

html - 如何将 div 元素向左移动一点

javascript - 我正在制作一个循环的连续图像 slider ,但我无法很好地过渡

c++ - 输出中意外的换行

python - 如何在Python中进行换行(续行)?

html - 绝对定位未按预期工作

css - 如何为轨道动画设置时间间隔

javascript -\r\n CSV 文件中的字符未被视为换行符