简体   繁体   English

如何在html中删除文本的第一行缩进

[英]How to remove first line indent of text in html

I'm having trouble formatting my output. 我在格式化输出时遇到问题。 I want each line of text to be horizontal on the left side. 我希望文本的每一行在左侧都是水平的。 Here is the code I am using. 这是我正在使用的代码。

<div style="text-align: left;">
    <pre style="width: 75%; margin-left:auto; margin-right:auto;"><code class="sql">
        <c:out value="${snippet.query}"/>
    </code></pre>
</div>

Although the styling calls for the text to be aligned to the left of the div, the first line of output is always indented. 尽管样式要求文本在div的左侧对齐,但输出的第一行始终缩进。 Why is this happening? 为什么会这样呢? I can't post images yet, but this is what it looks like: 我还不能发布图片,但这是它的样子:

            CREATE SCHEMA "Trading";
SET SCHEMA '"Trading"';
CREATE STREAM "Orders"
(
   orderTime TIMESTAMP,
   orderId INTEGER,
   productId INTEGER,
   quantity INTEGER,
   unitPrice DECIMAL(11,2),
   shippingState CHAR(2)
);
CREATE STREAM Shipments
(
   shipTime TIMESTAMP,
   orderId INTEGER,
   warehouseState CHAR(2)
);  

I notice that if I remove the 'pre' tags I no longer have this issue, but without those tags proper text highlighting does not occur. 我注意到,如果删除“ pre”标签,我将不再遇到此问题,但是如果没有这些标签,则不会出现正确的文本突出显示。 I'm passing the variable snippet to the jsp like this: 我正在将变量代码片段传递给jsp,如下所示:

  request.setAttribute("snippet", selectedQuery);

I've tested what this data looks like prior to sending it to the jsp. 在将数据发送到jsp之前,我已经对其进行了测试。 I observed the variable in System.out.print() and there is NO indentation on the String itself. 我在System.out.print()中观察到该变量,并且String本身没有缩进。 selectedQuery is an object that holds several String variables. selectedQuery是一个包含几个String变量的对象。

Thank you for your help. 谢谢您的帮助。

edit: I've tried using text-indent in the div, pre, and code tags but none of those had any effect. 编辑:我已经尝试在div,pre和code标记中使用text-indent,但是这些标记都没有任何作用。

The pre tag includes any white space. pre标签包含任何空格。 You have a bunch of white space between the opening and closing pre tags. 在开始和结束标记之间有很多空白。 Simply remove that and you should be fine :) 只需删除它,你就可以了:)

Like so: 像这样:

<div style="text-align: left;">
    <pre style="width: 75%; margin-left:auto; margin-right:auto;"><code class="sql">
        <c:out value="${snippet.query}"/>
    </code></pre>
</div>

To

<div style="text-align: left;">
    <pre style="width: 75%; margin-left:auto; margin-right:auto;"><code class="sql">
<c:out value="${snippet.query}"/>
    </code></pre>
</div>

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

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