PRE和空白行为 [英] PRE and white-spaces behavior

查看:180
本文介绍了PRE和空白行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在浏览器中显示一个txt文件,同时保持它的格式和布局。



我对pre标签的问题是它在行(i)前后添加的空间不需要)



白色空间可以很好地工作,但有时候会有一个随机的一行(或多行)截断。



我只在IE上测试它(因为它是用于内联网的,这里的人不会碰到另一个浏览器)。



我在IE浏览器上看到源代码,截断的行有正确的空白标记,但它在浏览器中无法正确显示。

 < p style =white-space:pre; display:inline;>这里的任何类型的文本< / p> 

这是浏览器的错误还是我的错误?
有没有更好的方法来做到这一点?
有没有办法从pre标签的行前后移除空格?

谢谢大家

最后,我遵循这里的建议:
HTML< pre>标签会导致换行符



无任何缺陷。


I'm trying to display a txt file in the browser while maintining it's format and layout. Now i have accomplished this with sucess using both the pre tag and white-spaces.

My problem with the pre tag is the space it adds before and after the line (i don't need that).

white-spaces works perfectly, but sometimes there will be a random line (or lines) wich will truncate.

I'm testing this only on IE (since it's for an intranet and folks here won't touch another browser).

When i see the source code on IE the lines wich are truncated have the correct white-spaces tag, but it does not display correctly on the browser.

<p style="white-space: pre;display: inline;">    Any    kind of   text      here </p>

Is this the browser's fault or my mistake? Is there a better way to do this? Is there a way to remove the spaces before and after the line from the pre tag?

Thank you all

解决方案

In the end i followed the suggestions here: HTML <pre> tag causes linebreaks

Worked without a flaw.

这篇关于PRE和空白行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆