删除 <pre> 中的空格标签 - html [英] removing spaces in <pre> tag - html
问题描述
我正在使用 pre 标签来显示一些文本文件,但问题是在开头和结尾,打印了 2-3 行新行.我如何删除它?我正在通过 http 请求获取文本文件,但无法修改文本文件,必须按原样显示.
或者有更好的方法来显示 html 中的文本文件吗?
我以前也遇到过类似的问题......我在我的 AngularJS 应用程序中遇到了这个问题,所以下面代码中的变量绑定等是基于那个)
假设你必须在变量 textFile.data 中显示数据(我将数据存储在 textFile.data 变量中)
<跨度>{{textFile.data}}</span>
显示 html 时添加了两个换行符,因为 pre 标记之间的任何内容都准确显示.所以添加了 2 行,因为在pre"标签之后和span"标签之后的 html 中添加了新行.
我改成这个
<pre ng-show = "textFile.isPresent"><span>{{textFile.data}}</span></pre>
执行此操作后删除了多余的行.请注意,您也可以通过修改 css 文件来删除它们.如果你不知道怎么做,评论,我会帮你的.
这只是原因之一,必须看你的代码,才能知道到底哪里错了
Hi I am using pre tag to dispaly some text files, but the problem is at the beginning and the end, 2-3 new lines are being printed. How do I remove that? I am getting the text file through http request and I cannot modify the text file, I have to display as is.
Or is there a better way to display text files in html?
I faced a similar problem in the past..... I think this could be a problem, can't tell for sure unless you share the code (I faced the problem in my AngularJS app, so the variable binding, etc. in the code below is based on that)
suppose you have to display the data in the variable textFile.data (I stored the data in textFile.data variable)
<pre ng-show = "textFile.isPresent">
<span>
{{textFile.data}}
</span>
</pre>
There are two new-line chars added when the html was displayed because whatever is there between pre tag is exactly shown. So 2 lines were added because of the new line in the html after "pre" tag and after "span" tag.
I changed it to this
<pre ng-show = "textFile.isPresent"><span>{{textFile.data}}</span></pre>
The extra lines were removed after doing this. Note that you can also remove them by modifying the css file. If you don't know how, comment, i'll help you out.
This is just one of the reasons, have to see your code, to tell what is exactly wrong
这篇关于删除 <pre> 中的空格标签 - html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!