inline_block_standards.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <!DOCTYPE html>
  2. <html>
  3. <!--
  4. Copyright 2010 The Closure Library Authors. All Rights Reserved.
  5. Use of this source code is governed by the Apache License, Version 2.0.
  6. See the COPYING file for details.
  7. -->
  8. <head>
  9. <title>goog.style.setInlineBlock in standards mode</title>
  10. <link rel="stylesheet" href="css/demo.css">
  11. <style>
  12. .container {
  13. margin: 20px;
  14. border: 1px solid black;
  15. padding: 20px;
  16. background-color: #ffc;
  17. }
  18. .demo {
  19. margin: 4px;
  20. border: 1px solid blue;
  21. padding: 4px;
  22. color: red;
  23. background-color: white;
  24. vertical-align: middle;
  25. }
  26. </style>
  27. <script src="../base.js"></script>
  28. <script>
  29. goog.require('goog.style');
  30. </script>
  31. <script>
  32. function inlineBlockify(tag, className, parentElement) {
  33. goog.array.forEach(
  34. goog.dom.getElementsByTagNameAndClass(tag, className, parentElement),
  35. function(el) {
  36. goog.style.setInlineBlock(el);
  37. });
  38. }
  39. function inlineBlockifyAll() {
  40. inlineBlockify('span', 'demo', goog.dom.getElement('foo'));
  41. }
  42. </script>
  43. </head>
  44. <body>
  45. <h1>goog.style.setInlineBlock in standards mode</h1>
  46. <p>
  47. This is a demonstration of the <code>goog-inline-block</code> CSS style.
  48. This page is in <strong>standards</strong> mode.
  49. <a href="inline_block_quirks.html">Click here for quirks mode.</a>
  50. </p>
  51. <div class="container">
  52. Hey, are these really
  53. <div class="demo goog-inline-block">DIV</div>s
  54. inlined in my text here? I mean, I thought
  55. <div class="demo goog-inline-block">DIV</div>s
  56. were block-level elements, and you couldn't inline them...
  57. Must be that new
  58. <div class="demo goog-inline-block">goog-inline-block</div>
  59. style... (Hint: Try resizing the window to see the
  60. <div class="demo goog-inline-block">DIV</div>s
  61. flow naturally.)
  62. Arv asked for an inline-block DIV with more interesting contents, so here
  63. goes:
  64. <div class="demo goog-inline-block">
  65. <div style="width:320px;font-size:80%;">
  66. <img src="../images/gears_bluedot.gif" alt="blue dot"
  67. style="float:left; margin: 0 1em 1em 0;"/>
  68. Lorem ipsum dolor sit amet,
  69. consectetuer adipiscing elit.
  70. Donec rhoncus neque ut
  71. neque porta consequat.
  72. In tincidunt tellus vehicula tellus. Etiam ornare nunc
  73. vel lectus. Vivamus quis nibh. Sed nunc.
  74. <strong>On FF1.5 and FF2.0, you need to wrap the contents of your
  75. inline-block element in a DIV or P with fixed width to get line
  76. wrapping.</strong>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="container">
  81. <p>
  82. These are
  83. <span class="demo goog-inline-block">SPAN</span>s
  84. with the
  85. <span class="demo goog-inline-block">goog-inline-block</span>
  86. style applied, so you can style them like block-level elements.
  87. For example, give them
  88. <span class="demo goog-inline-block" style="margin:10px;">10px margin</span>, a
  89. <span class="demo goog-inline-block" style="border-width:10px;">10px border</span>, or
  90. <span class="demo goog-inline-block" style="padding:10px;">10px padding</span>.
  91. I used
  92. <span class="demo goog-inline-block" style="">vertical-align: middle</span>
  93. to make them all line up reasonably well.
  94. (Except on Safari 2. Go figure.)
  95. </p>
  96. <p>
  97. This is what the same content looks like <strong>without goog-inline-block</strong>:
  98. </p>
  99. <p id="foo">
  100. These are
  101. <span class="demo">SPAN</span>s
  102. with the
  103. <span class="demo">goog-inline-block</span>
  104. style applied, so you can style them like block-level elements.
  105. For example, give them
  106. <span class="demo" style="margin:10px;">10px margin</span>, a
  107. <span class="demo" style="border-width:10px;">10px border</span>, or
  108. <span class="demo" style="padding:10px;">10px padding</span>.
  109. I used
  110. <span class="demo" style="">vertical-align: middle</span>
  111. to make them all line up reasonably well.
  112. (Except on Safari 2. Go figure.)
  113. </p>
  114. <p>
  115. <a href="#" onclick="inlineBlockifyAll();">Click here</a> to use <code>goog.style.setInlineBlock()</code> to apply the inline-block style to these SPANs.
  116. </p>
  117. </div>
  118. <p>
  119. Works on Internet Explorer 6 &amp; 7, Firefox 1.5, 2.0 &amp; 3.0 Beta, Safari 2 &amp; 3,
  120. Webkit nightlies, and Opera 9.
  121. <em><strong>Note:</strong> DIVs nested in SPANs don't work on Opera.</em>
  122. </p>
  123. </body>
  124. </html>