我尝试将PDF书籍变成一本mobi书(html),我也想重新创建布局。 在那里,每次休息后,文本都是一行。 这应该是
<body style="text-indent:20px each-line;">
但是我做错了,因为它不起作用。
我不想对段落执行此操作,因为默认情况下还包含空行,但这些段落并不总是意味着整个新段落......
答案 0 :(得分:2)
each-line
(请参阅text-indent
on MDN)。但是,这个是当它可用时你想要使用的东西。
答案 1 :(得分:2)
使用语义正确的段落标记<p>
并使用CSS根据需要修改填充/边距。
答案 2 :(得分:1)
段落是标记级别的方法。您描述的空白行是默认情况下由Web浏览器添加的边距。由于您已经在编辑样式表以添加文本缩进,因此覆盖这些默认边距应该没有麻烦。事实上,以下内容应该足够了:
p {
margin: 0;
text-indent: 2em
}
为什么2em
?这意味着该段落设置的字体m的宽度的两倍。因此,无论读者如何处理他或她的个人设置(字体大小,分辨率等),缩进都应与文本成比例。它也有点像印刷惯例。当然,您可以将此值设置为很多其他内容,例如20px
或1cm
。
答案 3 :(得分:0)
当运行代码片段时,它将为您提供示例HTML文本,您可以复制并粘贴并继续使用。
希望这会有所帮助。因为这是一种以您认为合适的方式放置文本的方法。谢谢!
<!DOCTYPE html>
<html>
<body>
<style>
h3 {
text-indent: 25px;
}
h3.small {
line-height: 0.2;
margin-top: 0em;
margin-bottom: 0em
}
h4.small {
line-height: 0.2;
margin-top: 1.5em;
margin-bottom: 1em;
}
</style>
<h1>Example</h1>
<h3 class="small">Put text where you want</h3>
<pre style="font-family:verdana">
This text will keep spacing.
This this line too.</pre>
<h4 class="small", style="text-indent: 50px">
This is how to make the above example, hope it helps:
</h4>
<pre>
<html>
<body>
<style>
h3 {
text-indent: 25px;
}
h3.small {
line-height: 0.2;
margin-top: 0em;
margin-bottom: 0em
}
h4.small {
line-height: 0.2;
margin-top: 1.5em;
margin-bottom: 1em;
}
</style>
<h1> Example </h1>
<h3> class="small">Put text where you want <h3>
<pre> style="font-family:verdana"
This text will keep spacing as formated in HTML file.
This line too.</pre>
</body>
</html></pre>
REFERENCE:
W3schools.com link to HTML <pre> Tag:
https://www.w3schools.com/tags/tag_pre.asp
W3schools.com link to HTML line height:
https://www.w3schools.com/css/tryit.asp?filename=trycss_line-height
W3schools.com link to HTML <p> tag default options:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_p_default_css</pre>
</body>
</html>