example10_floating_and_fixed_position_elements.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. $html = '
  3. <style>
  4. .gradient {
  5. border:0.1mm solid #220044;
  6. background-color: #f0f2ff;
  7. background-gradient: linear #c7cdde #f0f2ff 0 1 0 0.5;
  8. }
  9. h4 {
  10. font-family: sans;
  11. font-weight: bold;
  12. margin-top: 1em;
  13. margin-bottom: 0.5em;
  14. }
  15. div {
  16. padding:1em;
  17. margin-bottom: 1em;
  18. text-align:justify;
  19. }
  20. .myfixed1 { position: absolute;
  21. overflow: visible;
  22. left: 0;
  23. bottom: 0;
  24. border: 1px solid #880000;
  25. background-color: #FFEEDD;
  26. background-gradient: linear #dec7cd #fff0f2 0 1 0 0.5;
  27. padding: 1.5em;
  28. font-family:sans;
  29. margin: 0;
  30. }
  31. .myfixed2 { position: fixed;
  32. overflow: auto;
  33. right: 0;
  34. bottom: 0mm;
  35. width: 65mm;
  36. border: 1px solid #880000;
  37. background-color: #FFEEDD;
  38. background-gradient: linear #dec7cd #fff0f2 0 1 0 0.5;
  39. padding: 0.5em;
  40. font-family:sans;
  41. margin: 0;
  42. rotate: 90;
  43. }
  44. </style>
  45. <body>
  46. <h1>mPDF</h1>
  47. <h2>Floating & Fixed Position elements</h2>
  48. <h4>CSS "Float"</h4>
  49. <div class="gradient">
  50. Block elements can be positioned alongside each other using the CSS property float: left or right. The clear property can also be used, set as left|right|both. Float is only supported on block elements (i.e. not SPAN etc.) and is not fully compliant with the CSS specification.
  51. Float only works properly if a width is set for the float, otherwise the width is set to the maximum available (full width, or less if floats already set).
  52. <br />
  53. Margin-right can still be set for a float:right and vice-versa.
  54. <br />
  55. A block element next to a float has the padding adjusted so that content fits in the remaining width. Text next to a float should wrap correctly, but backgrounds and borders will overlap and/or lie under the floats in a mess.
  56. <br />
  57. NB The width that is set defines the width of the content-box. So if you have two floats with width=50% and either of them has padding, margin or border, they will not fit together on the page.
  58. </div>
  59. <div class="gradient" style="float: right; width: 28%; margin-bottom: 0pt; ">
  60. <img src="tiger.wmf" style="float:right" width="70" />This is text in a &lt;div&gt; element that is set to float:right and width:28%. It also has an image with float:right inside. With this exception, you cannot nest elements with the float property set inside one another.
  61. </div>
  62. <div class="gradient" style="float: left; width: 54%; margin-bottom: 0pt; ">
  63. This is text in a &lt;div&gt; element that is set to float:left and width:54%.
  64. </div>
  65. <div style="clear: both; margin: 0pt; padding: 0pt; "></div>
  66. This is text that follows a &lt;div&gt; element that is set to clear:both.
  67. <h4>CSS "Position"</h4>
  68. At the bottom of the page are two DIV elements with position:fixed and position:absolute set
  69. <div class="myfixed1">1 Praesent pharetra nulla in turpis. Sed ipsum nulla, sodales nec, vulputate in, scelerisque vitae, magna. Praesent pharetra nulla in turpis. Sed ipsum nulla, sodales nec, vulputate in, scelerisque vitae, magna. Sed egestas justo nec ipsum. Nulla facilisi. Praesent sit amet pede quis metus aliquet vulputate. Donec luctus. Cras euismod tellus vel leo. Sed egestas justo nec ipsum. Nulla facilisi. Praesent sit amet pede quis metus aliquet vulputate. Donec luctus. Cras euismod tellus vel leo.</div>
  70. <div class="myfixed2">2 Praesent pharetra nulla in turpis. Sed ipsum nulla, sodales nec, vulputate in, scelerisque vitae, magna. Sed egestas justo nec ipsum. Nulla facilisi. Praesent sit amet pede quis metus aliquet vulputate. Donec luctus. Cras euismod tellus vel leo.</div>
  71. ';
  72. //==============================================================
  73. //==============================================================
  74. //==============================================================
  75. include("../mpdf.php");
  76. $mpdf=new mPDF('s');
  77. $mpdf->SetDisplayMode('fullpage');
  78. $mpdf->WriteHTML($html); // Separate Paragraphs defined by font
  79. $mpdf->Output();
  80. exit;
  81. //==============================================================
  82. //==============================================================
  83. //==============================================================
  84. ?>