styles.scss 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. @import "scss/setup.scss";
  2. /**
  3. * Computation
  4. */
  5. /* EXTRA SPACE AROUND THE PAGE: BLEED + CROP */
  6. // TODO: find a more appropriate name
  7. $crop: $crop-size + $bleed;
  8. /* GEOMETRY OF THE PAPER SHEET */
  9. $paper-width: $page-width + ( $crop * 2 );
  10. $paper-height: $page-height + ( $crop * 2 );
  11. /* SIZE OF SPREAD */
  12. $spread: $page-width * 2;
  13. /**
  14. * DEFINITION OF THE PAPER SHEET
  15. */
  16. @page {
  17. size: $paper-width ($paper-height + 1);
  18. margin: 0;
  19. }
  20. /**
  21. * CANVAS
  22. */
  23. @media all {
  24. body {
  25. margin: 0;
  26. }
  27. .paper {
  28. width: $paper-width;
  29. height: $paper-height;
  30. box-sizing: border-box;
  31. counter-increment: page-counter;
  32. // To make sure that one paper sheet is not splitted into different pages in the PDF
  33. page-break-inside: avoid;
  34. page-break-after: always;
  35. overflow: hidden;
  36. }
  37. .page {
  38. width: $page-width;
  39. height: $page-height;
  40. position: relative;
  41. }
  42. }
  43. @media print {
  44. html {
  45. width: $paper-width;
  46. }
  47. body {
  48. /* Allows printing of background colors */
  49. background-color: white;
  50. -webkit-print-color-adjust: exact;
  51. print-color-adjust: exact;
  52. /* Activate opentype features and kernings */
  53. -webkit-font-feature-settings: "liga", "dlig", "clig", "kern";
  54. text-rendering: optimizeLegibility;
  55. }
  56. }
  57. /**
  58. * Helpers
  59. */
  60. .page-break {
  61. /* Apply this class to an element to put it on a new region.
  62. * Hint:
  63. * You can also use an empty <div class="page-break"></div>
  64. * if you want to put manual page breaks without attaching it to an HTML element
  65. */
  66. // -webkit-region-break-before: always;
  67. break-after: region;
  68. }
  69. // section.level1, section.level2{
  70. // break-after: always;
  71. // }
  72. /* __________________________________ LAYOUT __________________________________ */
  73. .header,
  74. .body,
  75. .footer {
  76. box-sizing: border-box;
  77. }
  78. /* __________________________________ HEADER __________________________________ */
  79. .header {
  80. top: 0;
  81. margin: 0;
  82. padding-top: $page-margin-top;
  83. width: 100%;
  84. height: $header-height;
  85. text-align: left;
  86. &:after {
  87. content: $header-text;
  88. }
  89. }
  90. /* __________________________________ MAIN SECTION __________________________________ */
  91. .body {
  92. height: $page-height - $header-height - $footer-height;
  93. width: $page-width;
  94. margin-bottom: $page-margin-bottom;
  95. padding-top: $page-margin-top + $header-height;
  96. padding-bottom: $page-margin-bottom;
  97. position: absolute;
  98. }
  99. .recipient {
  100. -webkit-flow-from: contentFlow;
  101. flow-from: contentFlow;
  102. }
  103. #content > * {
  104. -webkit-flow-into: contentFlow;
  105. flow-into: contentFlow contents;
  106. }
  107. /* __________________________________ FOOTER __________________________________ */
  108. .footer {
  109. position: absolute;
  110. bottom: 0;
  111. margin: 0;
  112. width: 100%;
  113. height: $footer-height;
  114. text-align: center;
  115. &:after {
  116. content: $footer-text;
  117. }
  118. }
  119. /* mirrored pages */
  120. .paper {
  121. &:nth-child(odd) .header {
  122. @if $page-layout == 2 {text-align: right;}
  123. }
  124. &:nth-child(odd) .header,
  125. &:nth-child(odd) .body,
  126. &:nth-child(odd) .footer {
  127. padding-left: $page-margin-inside;
  128. padding-right: $page-margin-outside;
  129. }
  130. &:nth-child(even) .header,
  131. &:nth-child(even) .body,
  132. &:nth-child(even) .footer {
  133. padding-left: $page-margin-outside;
  134. padding-right: $page-margin-inside;
  135. }
  136. }
  137. img {
  138. max-width: 100%;
  139. }
  140. h1,
  141. h2,
  142. h3,
  143. h4,
  144. h5,
  145. h6 {
  146. /* Avoids headings to be cut or to be orphans.
  147. * But it doesn't seem to work
  148. * if the element after has a page-break-inside avoid. It tries its best! */
  149. -webkit-region-break-inside: avoid;
  150. -webkit-region-break-after: avoid;
  151. break-inside: avoid;
  152. break-after: avoid;
  153. }
  154. /* AN EXAMPLE TO AVOID PAGE BREAK INSIDE,
  155. * HERE NO PARAGRAPH WILL BE CUT,
  156. * BUT YOU MIGHT WANT TO DEACTIVATE THIS */
  157. p {
  158. /*-webkit-region-break-inside: avoid;*/
  159. }
  160. /**
  161. * DEBUG STYLES
  162. */
  163. .debug .paper {
  164. outline: 1px solid blue;
  165. }
  166. .debug .page {
  167. outline: 1px solid green;
  168. }
  169. .debug .header {
  170. outline: 1px solid pink;
  171. }
  172. .debug .body {
  173. outline: 1px solid purple;
  174. }
  175. .debug .footer {
  176. outline: 1px solid pink;
  177. }
  178. .debug .region-break {
  179. border-top: 1px dashed blue;
  180. box-sizing: border-box;
  181. }
  182. .debug img {
  183. outline: 1px solid blue;
  184. }
  185. /**
  186. * Style
  187. */
  188. @media screen{
  189. body{
  190. background-color: #EEE;
  191. }
  192. .paper{
  193. background-color: #fff;
  194. box-shadow: 0 0 10px 7px #AAA;
  195. margin: 20px;
  196. }
  197. }
  198. @import "scss/custom.scss";