|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | + <head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>Inline Formatting Context - alignment</title> |
| 6 | + |
| 7 | + <style> |
| 8 | + body { |
| 9 | + font: 1.2em Helvetica, Arial, sans-serif; |
| 10 | + margin: 20px; |
| 11 | + padding: 0; |
| 12 | + } |
| 13 | + |
| 14 | + textarea { |
| 15 | + font-family: monospace; |
| 16 | + display: block; |
| 17 | + margin-bottom: 10px; |
| 18 | + background-color: #f4f7f8; |
| 19 | + border: none; |
| 20 | + border-left: 6px solid #558abb; |
| 21 | + color: #4d4e53; |
| 22 | + width: 90%; |
| 23 | + max-width: 700px; |
| 24 | + padding: 10px 10px 0px; |
| 25 | + font-size: 90%; |
| 26 | + } |
| 27 | + |
| 28 | + textarea:nth-of-type(1) { |
| 29 | + height: 120px; |
| 30 | + } |
| 31 | + |
| 32 | + textarea:nth-of-type(2) { |
| 33 | + height: 160px; |
| 34 | + } |
| 35 | + |
| 36 | + .playable-buttons { |
| 37 | + text-align: right; |
| 38 | + width: 90%; |
| 39 | + max-width: 700px; |
| 40 | + padding: 5px 10px 5px 26px; |
| 41 | + font-size: 100%; |
| 42 | + } |
| 43 | + |
| 44 | + section { |
| 45 | + width: 90%; |
| 46 | + max-width: 700px; |
| 47 | + border: 1px solid #4d4e53; |
| 48 | + border-radius: 2px; |
| 49 | + padding: 10px 14px 10px 10px; |
| 50 | + margin-bottom: 10px; |
| 51 | + } |
| 52 | + |
| 53 | + section input { |
| 54 | + display: block; |
| 55 | + margin: 5px; |
| 56 | + } |
| 57 | + |
| 58 | + .example { |
| 59 | + border: 5px solid black; |
| 60 | + margin: 20px; |
| 61 | + inline-size: 400px; |
| 62 | + } |
| 63 | + |
| 64 | + .horizontal { |
| 65 | + writing-mode: horizontal-tb; |
| 66 | + } |
| 67 | + |
| 68 | + .vertical { |
| 69 | + writing-mode: vertical-rl; |
| 70 | + } |
| 71 | + </style> |
| 72 | + |
| 73 | + <style class="editable"> |
| 74 | + span { |
| 75 | + font-size: 200%; |
| 76 | + vertical-align: top; |
| 77 | + } |
| 78 | + </style> |
| 79 | + </head> |
| 80 | + |
| 81 | + <body> |
| 82 | + <section> |
| 83 | + <div class="example horizontal"> |
| 84 | + Before that night—<span>a memorable night</span>, as it was to |
| 85 | + prove—hundreds of millions of people had watched the rising |
| 86 | + smoke-wreaths of their fires without drawing any special inspiration |
| 87 | + from the fact.” |
| 88 | + </div> |
| 89 | + |
| 90 | + <div class="example vertical"> |
| 91 | + Before that night—<span>a memorable night</span>, as it was to |
| 92 | + prove—hundreds of millions of people had watched the rising |
| 93 | + smoke-wreaths of their fires without drawing any special inspiration |
| 94 | + from the fact.” |
| 95 | + </div> |
| 96 | + </section> |
| 97 | + <textarea class="playable-css"> |
| 98 | +span { |
| 99 | + font-size: 200%; |
| 100 | + vertical-align: top; |
| 101 | +} |
| 102 | + </textarea |
| 103 | + > |
| 104 | + |
| 105 | + <textarea id="code" class="playable-html"> |
| 106 | + |
| 107 | +<div class="example horizontal"> |
| 108 | + Before that night—<span>a memorable night</span>, as it was to prove—hundreds of millions of people had watched the rising smoke-wreaths of their fires without drawing any special inspiration from the fact.” |
| 109 | +</div> |
| 110 | + |
| 111 | +<div class="example vertical"> |
| 112 | + Before that night—<span>a memorable night</span>, as it was to prove—hundreds of millions of people had watched the rising smoke-wreaths of their fires without drawing any special inspiration from the fact.” |
| 113 | +</div> |
| 114 | + |
| 115 | + </textarea> |
| 116 | + <div class="playable-buttons"> |
| 117 | + <input id="reset" type="button" value="Reset" /> |
| 118 | + </div> |
| 119 | + </body> |
| 120 | + <script> |
| 121 | + var section = document.querySelector("section"); |
| 122 | + var editable = document.querySelector(".editable"); |
| 123 | + var textareaHTML = document.querySelector(".playable-html"); |
| 124 | + var textareaCSS = document.querySelector(".playable-css"); |
| 125 | + var reset = document.getElementById("reset"); |
| 126 | + var htmlCode = textareaHTML.value; |
| 127 | + var cssCode = textareaCSS.value; |
| 128 | + |
| 129 | + function fillCode() { |
| 130 | + editable.innerHTML = textareaCSS.value; |
| 131 | + section.innerHTML = textareaHTML.value; |
| 132 | + } |
| 133 | + |
| 134 | + reset.addEventListener("click", function() { |
| 135 | + textareaHTML.value = htmlCode; |
| 136 | + textareaCSS.value = cssCode; |
| 137 | + fillCode(); |
| 138 | + }); |
| 139 | + |
| 140 | + textareaHTML.addEventListener("input", fillCode); |
| 141 | + textareaCSS.addEventListener("input", fillCode); |
| 142 | + window.addEventListener("load", fillCode); |
| 143 | + </script> |
| 144 | +</html> |
0 commit comments