CSS 和打印:将文本块保持在一起
这是典型的多项选择题考试,假设问题格式:
<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>
我已经将所有这些都映射到带有网络单选按钮的适当样式。
现在,我需要制作测试的可打印版本。这实际上更简单,因为我不需要包含无线电,只需“___”作为复选标记。主要问题是如何防止问题因分页符而分裂。
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>
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我从来没有幸运地持续阻止类似的事情发生。这可能有点脏,但如果问题通常长度相同,您可以在每 X 个问题之后强制分页吗?
(或者将该类应用于问题或任何您想要的)
您可以尝试使用 page-break-inside 属性,但我还没有看到它是一致的,因为浏览器对它的支持现在很混乱:
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?
(Or apply that class to the question or whatever you want)
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:
我建议您查看
page-break-after
、page-break-inside
和page-break-before
CSS 中的规则。I'd suggest you look into
page-break-after
,page-break-inside
andpage-break-before
rules in CSS.使用单独的打印样式表,并使用
page-break-before
和page-break-after
选择器来设置每页上的开头和结尾问题。如果测验是静态的,您可以绘制所使用的类并使其正常运行,而无需任何 CSS 之外的东西。
Use a separate print stylesheet, and use the
page-break-before
andpage-break-after
selectors for your leading and ending questions on each page.If the quiz is static, you can plot the classes you use out and make it work without anything more than CSS.
使用表格布局。但为了避免改变语义,请使用 CSS。
Use a table layout. But to avoid changing the semantics, use CSS.