简体   繁体   English

禁用HTML缩小,而不是JavaScript或CSS

[英]Disable HTML minification not JavaScript or CSS

I am facing UI related issues due to my HTML is being minified. 由于我的HTML正在缩小,因此我面临与UI相关的问题。 New lines are being removed. 新行将被删除。 I am working in ASP.NET from around 2 years. 我在ASP.NET中工作大约2年。 I hadn't faced any such issue before. 我以前没有遇到过这样的问题。 This is a new project so may be there is something new in newer version (MVC 5) which is causing this. 这是一个新项目,因此可能是由于较新版本(MVC 5)引起的。

I have following HTML 我有以下HTML

<p style="white-space:pre-line">
    <i class="fa fa-file-word-o"></i> <span style="font-weight:bold">Address Work</span>
    House Number and Street
    Colony
    City
    State ZIP
</p>

You can see if I remove new lines from HTML it will change the appearance. 您可以看到我是否从HTML中删除新行,它将改变外观。 Everything will be displayed in one line because I have applied white-space:pre-line . 因为我已经应用了white-space:pre-line所以所有内容都将显示在white-space:pre-line New lines are important to me here. 在这里,换行对我很重要。

HTML is not minified in development server (localhost). 在开发服务器(localhost)中未缩小HTML。 It is getting minified in production server (build using Publishing). 它在生产服务器(使用发布进行构建)中越来越小。

And the interesting thing is when I do a hard-refresh ( Ctrl + F5 ). 有趣的是,当我进行硬刷新( Ctrl + F5 )时。 The server will not minify HTML. 服务器不会缩小HTML。 In case of normal F5 refresh, or in redirecting, HTML will be minified. 在正常F5刷新或重定向的情况下,HTML将被最小化。 How did server get to know that I am requesting content with a hard refresh? 服务器如何得知我要硬刷新内容? and Why it serves different HTML for such requests? 为什么为此类请求提供不同的HTML?

How can I disable HTML minification when I am not in debug mode on production server? 当我不在生产服务器上处于调试模式时,如何禁用HTML压缩?

You write in paragraph ( <p> tag) so it shows what its written there, the simplest solution is to write <br> to break each line. 您在段落( <p>标记)中编写代码,以便显示其内容,最简单的解决方案是编写<br>来打破每一行。

<p style="white-space:pre-line">
    <i class="fa fa-file-word-o"></i> <span style="font-weight:bold">Address Work</span><br>
   House Number and Street<br>
   Colony<br>
   City<br>
   State ZIP 
</p>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM