CSS和打印:将文本块保存在一起 [英] CSS and Printing : Keep block of text together
问题描述
这是一个典型的多选择考试,假设一个问题格式:
This is a typical Multiple Choice exam, Assume a question format:
<question qid='1'>
<stem>What is your name?</stem>
<choice value = 'a'>Arthur, King of the Britons</choice>
<choice value = 'b'>There are some who call me ... Tim!</choice>
<choice value = 'c'>He is brave Sir Robin, brave Sir Robin, who-- Shut up! Um, n-- n-- n-- nobody, really. I'm j-- j-- j-- ju-- just, um-- just passing through.</choice>
<choice value = 'd'>Sir Galahad... the Chaste.</choice>
<choice value = 'e'>Zoot... Just Zoot.</choice>
</question>
我已经将所有映射到适当的风格与web单选按钮。
and I've got this all mapped to appropriate styles with radio buttons for the web.
现在,我需要打印一个测试版本。这实际上更简单,因为我不需要包括无线电,只是'___'一个复选标记。主要的问题是如何防止分割分页的问题。
Now, I need to make a printable version of the test. This is actually simpler, in that I don't need to include radios, just '___' for a check mark. The major issue is how to keep the question from splitting over the page break.
推荐答案
我从未有幸运地一直阻止这样的事情。这可能有点脏,但如果问题通常是相同的长度,你可以强制一个分页后每X个问题?
I haven't ever had luck with consistently preventing something like that. It may be a bit dirty, but if the questions are usually of the sameish length can you force a page-break after every X questions?
<style type="text/css">
.pageBreak{
page-break-before: always;
}
</style>
<question>...</question><br class="pageBreak" />
<question>...</question>
(或将此类应用于问题或任何您想要的)
(Or apply that class to the question or whatever you want)
您可以尝试使用page-break-inside属性,但是我没有看到它是一致的,因为浏览器支持它现在是一个混乱:
You can try using the page-break-inside property, but I haven't seen it be consistent as browser support for it is a mess right now:
question {
page-break-inside:avoid;
}
这篇关于CSS和打印:将文本块保存在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!