inline_block_quirks.html 4.6 KB

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