Debian Codegraph @

closure-library/closure/goog/demos/inline_block_quirks.html

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