example.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <!DOCTYPE html>
  2. <html lang="zh-cn">
  3. <head>
  4. <title>试卷</title>
  5. <meta charset="UTF-8"/>
  6. <meta name="renderer" content="webkit"/>
  7. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  8. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
  9. <style type="text/css">
  10. * {
  11. font-family: "宋体";
  12. font-size: 22px;
  13. line-height: 1.5;
  14. }
  15. .e_description {
  16. padding: 50px 0;
  17. }
  18. .e_description span {
  19. display: inline-block;
  20. width: 48%;
  21. line-height: 40px;
  22. font-weight: 700;
  23. }
  24. .e_description em {
  25. font-style: normal;
  26. margin-left: 10px;
  27. text-align: center;
  28. text-decoration: underline;
  29. }
  30. .e_page_no {
  31. z-index: 1;
  32. display: block;
  33. width: 50px;
  34. height: 20px;
  35. line-height: 20px;
  36. text-align: right;
  37. position: absolute;
  38. right: 0;
  39. bottom: 0;
  40. font-weight: 700;
  41. color: #666;
  42. }
  43. .e_paper_title {
  44. height: 400px;
  45. }
  46. .e_paper_title h1 {
  47. font-size: 2.2em;
  48. font-family: "黑体";
  49. font-weight: bolder;
  50. text-align: center;
  51. }
  52. .e_paper_title h3 {
  53. margin-top: -20px;
  54. font-size: 30px;
  55. font-family: "黑体";
  56. text-align: center;
  57. }
  58. .e_paper_title h3 b, .e_paper_title h3 em {
  59. font-style: normal;
  60. font-size: 30px;
  61. color: #f00;
  62. }
  63. .e_paper_title h3 em {
  64. font-family: "Times New Roman", Times, serif;
  65. }
  66. .e_tip {
  67. margin-top: 10px;
  68. }
  69. /* 第一版面 */
  70. .e_first_page {
  71. width: 2250px;
  72. margin-left: 50px;
  73. position: relative;
  74. }
  75. .e_first_part {
  76. position: absolute;
  77. width: 1560px;
  78. height: 120px;
  79. position: absolute;
  80. top: 742px;
  81. left: -715px;
  82. /* 逆时针旋转90度 */
  83. transform: rotateZ(270deg);
  84. -webkit-transform: rotateZ(270deg);
  85. /* 往左平移 */
  86. }
  87. /* 侧边栏 */
  88. .e_sidebar_font {
  89. text-align: center;
  90. }
  91. .e_sidebar_font span {
  92. margin-left: 30px;
  93. }
  94. /* 密封线 */
  95. .e_sidebar_thread {
  96. margin-top: 15px;
  97. border-bottom: 0.1em dotted #333;
  98. height: 20px;
  99. line-height: 25px;
  100. text-align: center;
  101. }
  102. .e_sidebar_thread span {
  103. margin: 0 150px;
  104. background: #FFF;
  105. }
  106. #allContent {
  107. width: 2000px;
  108. float: left;
  109. padding-left: 130px;
  110. }
  111. #tempContent {
  112. visibility: hidden;
  113. width: 990px;
  114. }
  115. .e_detail {
  116. /* nothing */
  117. }
  118. .e_question {
  119. /* nothing */
  120. }
  121. .e_option {
  122. /* nothing */
  123. }
  124. .e_item {
  125. display: inline-block;
  126. line-height: 20px;
  127. padding-right: 15px;
  128. box-sizing: border-box;
  129. -webkit-box-zizig: border-box;
  130. }
  131. .e_w25 {
  132. width: 25%;
  133. }
  134. .e_w50 {
  135. width: 50%;
  136. }
  137. .e_w100 {
  138. width: 100%;
  139. }
  140. .e_num {
  141. font-style: normal;
  142. color: red;
  143. }
  144. .e_box {
  145. /*background: #ccc;*/
  146. float: left;
  147. width: 100%;
  148. overflow: hidden;
  149. }
  150. .e_box p {
  151. margin: 0 !important;
  152. }
  153. .e_box p.e_option_end {
  154. margin-bottom: 30px !important;
  155. }
  156. .e_content {
  157. /*background: #efefef;*/
  158. float: left;
  159. width: 960px;
  160. height: 1593px;
  161. margin: 20px;
  162. padding-bottom: 30px;
  163. position: relative;
  164. border-top: 0px dashed black;
  165. border-bottom: 0px dashed black;
  166. box-sizing: border-box;
  167. }
  168. @media print {
  169. .e_content:nth-child(even) {
  170. page-break-before: always;
  171. }
  172. .e_content:first-child {
  173. page-break-before: auto;
  174. }
  175. @page {
  176. size: A3 landscape;
  177. }
  178. }
  179. </style>
  180. </head>
  181. <body>
  182. <div class="e_first_page">
  183. <div class="e_first_part">
  184. <div class="e_sidebar_font">
  185. <span style="margin-left: 0">学习中心________________________</span>
  186. <span>姓名________________________</span>
  187. <span>学校________________________</span>
  188. <span>专业名称________________________</span>
  189. </div>
  190. <div class="e_sidebar_thread">
  191. <span>密</span>
  192. <span>封</span>
  193. <span>线</span>
  194. </div>
  195. </div>
  196. <div id="allContent">
  197. <div class="e_content">
  198. <div id="e_box_0" class="e_box">
  199. <div class="e_paper_title">
  200. <h1>山东大学继续(网络)教育</h1>
  201. <h3><b><em>2019</em>年<em>06</em>月</b>期末考试</h3>
  202. <div class="e_description">
  203. <span>课程名称:<em style="color: #FF0000">模拟电路基础</em></span>
  204. <span>课程代码:<em style="color: #FF0000">100920921</em></span>
  205. <span>考试时间:<em>90分钟</em></span>
  206. <span>课程层次:<em style="color: #FF0000">高起专</em></span>
  207. </div>
  208. <div class="e_tip"><span><b>注意事项:必须按试题顺序在“答题卡”上按要求填涂、作答,答在试卷上的答案无效。</b></span></div>
  209. </div>
  210. </div>
  211. <span class="e_page_no">-1-</span>
  212. </div>
  213. </div>
  214. </div>
  215. <!-- 临时内容DIV -->
  216. <div id="tempContent"></div>
  217. </body>
  218. <script type="text/javascript">
  219. var a3Width = 930;
  220. var a3Height = 1593;
  221. var tempContent = document.getElementById("tempContent");
  222. var tempOptions = [];
  223. var theBox = document.getElementById("e_box_0");
  224. var boxIndex = 0;
  225. function renderQuestions(list) {
  226. for (var i = 0; i < list.length; i++) {
  227. var div = createElement(list[i], i);
  228. if (div.className.indexOf("e_item") > -1) {
  229. /* 选项 */
  230. tempOptions.push(div);
  231. tempContent.appendChild(div);
  232. } else if ((div.className.indexOf("e_detail") > -1 || div.className.indexOf("e_question") > -1) && tempOptions.length > 0) {
  233. /* 大题或小题 */
  234. handleQuestionOption();
  235. appendBox(div);
  236. } else {
  237. appendBox(div);
  238. }
  239. }
  240. /* 处理最后一题选项 */
  241. if (tempOptions.length > 0) {
  242. handleQuestionOption();
  243. }
  244. console.log('finished');
  245. }
  246. function createElement(val, index) {
  247. var divElement = document.createElement('div');
  248. var className = "";
  249. if (val.indexOf("e_detail") > -1) {
  250. className = "e_detail";
  251. }
  252. if (val.indexOf("e_question") > -1) {
  253. className = "e_question";
  254. }
  255. if (val.indexOf("e_option") > -1) {
  256. className = "e_item e_option_end";
  257. }
  258. divElement.setAttribute('class', className);
  259. divElement.setAttribute('e_index', index);
  260. divElement.innerHTML = val;
  261. return divElement;
  262. }
  263. function createPager(pageNo) {
  264. var span = document.createElement('span');
  265. span.setAttribute("class", "e_page_no");
  266. span.innerText = '-' + pageNo + '-';
  267. return span;
  268. }
  269. function appendBox(elements) {
  270. theBox.appendChild(elements);
  271. var curHeight = theBox.clientHeight;
  272. if (curHeight > a3Height) {
  273. theBox.removeChild(elements);
  274. boxIndex++;
  275. var allContent = document.getElementById("allContent");
  276. var curContent = document.createElement('div');
  277. curContent.setAttribute('class', 'e_content');
  278. if (boxIndex % 2 == 0) {
  279. var curPager = createPager((boxIndex / 2) + 1);
  280. curContent.appendChild(curPager);
  281. }
  282. var curBox = document.createElement('div');
  283. var curBoxIndex = "e_box_" + boxIndex;
  284. curBox.id = curBoxIndex;
  285. curBox.setAttribute('class', 'e_box');
  286. curBox.appendChild(elements);
  287. curContent.appendChild(curBox);
  288. allContent.appendChild(curContent);
  289. theBox = document.getElementById(curBoxIndex);
  290. }
  291. }
  292. function handleQuestionOption() {
  293. var className = calculateLine(tempOptions);
  294. tempContent.innerHTML = '';
  295. tempOptions.forEach(function (item) {
  296. item.setAttribute('class', 'e_item ' + className);
  297. appendBox(item);
  298. });
  299. tempOptions = [];
  300. }
  301. function calculateLine(options) {
  302. var className = 'e_w25';
  303. for (var i = 0; i < options.length; i++) {
  304. var rate = options[i].clientWidth / a3Width;
  305. if (rate > 0.5) {
  306. className = 'e_w100';
  307. return className
  308. }
  309. if (rate > 0.25) {
  310. className = 'e_w50';
  311. }
  312. }
  313. return className;
  314. }
  315. window.onload = function () {
  316. /* 后台数据示例 */
  317. var list = [];
  318. for (var m = 1; m <= 15; m++) {
  319. list.push('<p class="e_detail"><b>一、单选题(本大题共<i class="e_num">50</i>小题,共<i class="e_num">100</i>分)</b></p>');
  320. list.push('<p><b>在每小题列出的备选项中只有一个符合题目要求的,请将其选出并将“答题卡”的相应代码涂黑,错涂、多涂或未涂均无分。</b></p>');
  321. var content = '';
  322. for (var n = 1; n <= 50; n++) {
  323. if (n <= 30) {
  324. content += '选项';
  325. }
  326. list.push('<p class="e_question">' + n + '、题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干题干?(2分)</p>');
  327. list.push('<p class="e_option">A.选项</p>');
  328. list.push('<p class="e_option">B.选项选项</p>');
  329. list.push('<p class="e_option">C.选项选项选项</p>');
  330. list.push('<p class="e_option e_option_end">D.' + content + '</p>');
  331. }
  332. }
  333. renderQuestions(list);
  334. };
  335. </script>
  336. </html>