CSS:如何在元素内容前添加空格? [英] CSS: how to add white space before element's content?
本文介绍了CSS:如何在元素内容前添加空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下代码均无效:
p:before { content: " "; }
p:before { content: " "; }
如何在元素内容之前添加空格?
注意:我需要为左边框和左边框上色以供语义使用,并将空格用作无色边框. :)
Note: I need to color the border-left and the margin-left for semantic use and use the space as colorless margin. :)
推荐答案
您可以使用不间断空格的unicode:
You can use the unicode of a non breaking space :
p:before { content: "\00a0 "; }
请参见 JSfiddle演示
See JSfiddle demo
[样式由@Jason Sperske改进]
[style improved by @Jason Sperske]
这篇关于CSS:如何在元素内容前添加空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文