3

我在<p>使用 Internet Explorer 的 Active-X 插件打印页面时如何呈现 text-indent 属性时遇到问题。这是相关的CSS:

p {
font-family: Calibri;
font-size: 20pt;
line-height: 1.75em;
margin-bottom: 1.00em;  
margin-top: 1.00em;
margin-left:1.0em;
margin-right:1.0em; 
text-indent:1.5em;  
}

您可以在下面看到使用上述代码打印 HTML 页面时发生的情况:

渲染不当

每个新页面的顶部都应用了文本缩进!是否有另一种方法可以在<p>不使用“text-indent”属性的情况下缩进每个“段落标签”的第一行?解决方案必须独立于浏览器。

4

2 回答 2

6

使用::first-letter伪元素怎么样?

p:first-letter {
    padding-left: 30px;
}

JsFiddle 演示

浏览器支持

Chrome    Safari    Firefox    Opera    IE      Android    iOS
1+        1+        1+         3.5+     5.5+    All        All
于 2013-07-07T21:07:16.260 回答
2

You could use pseudo elements to mimic the effect of text-indent

p:before
{
    content: '\00A0 \00A0 \00A0 \00A0 \00A0 \00A0 \00A0';
    dispay:inline-block;
}

FIDDLE


EDIT: (As per the questioner's comments below)

If the above CSS solution(s) don't work for you, then maybe instead of using css

you could just append a fixed number of non-breaking spaces after each paragraph element.

Like so <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ...

FIDDLE

You could do this simply by copy/replace:

 <p> -> <p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; ...
于 2013-07-07T12:20:06.930 回答