我正在使用CSS(通过JQuery,但与此问题无关)突出显示HTML文件中的某些元素:我使用"pre"标签来分隔我文件中的逻辑元素,但我注意到"pre"标签似乎在元素之间留下了新的界限.
我可以使用CSS摆脱这些吗?
(或者我应该使用什么而不是"pre"标签?文本元素可能包含自己的HTML元素:不应该呈现,并且应该按字面显示为源代码:因此我最初选择"pre"标签)
This is an error line.
stack.trace.blah.blah
more.blah.blah
yadda.yadda.blah
this is not an error line.it contains html
<html><head></head><body>hello</body></html>
This is an error line.
stack.trace.blah.blah
more.blah.blah
yadda.yadda.blah
$("pre.error").css({"background-color":"red","color":"white","display":"block","padding":"0", "margin":"0"});
我正在使用Firefox 3.6.12.这就是上面的代码导致的结果:
这是我想要的模拟输出(切换到黄色,只是因为我使用了我的vim编辑器,假装它是红色的!)
解:
是对所有PRE标签使用'display:inline'.(之前我只是将'display:inline'应用于上面示例中的'error'标记,并且忘记对'ok'预标签执行相同操作.