Debian Codegraph @

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

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