aboutsummaryrefslogtreecommitdiff
path: root/contexts/data/lib/closure-library/closure/goog/demos/inline_block_standards.html
blob: 5f4304893fb843351ed7a4f81dfbceb8b070841c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<!DOCTYPE html>
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.

Use of this source code is governed by the Apache License, Version 2.0.
See the COPYING file for details.
-->
<head>
  <title>goog.style.setInlineBlock in standards mode</title>
  <link rel="stylesheet" href="css/demo.css">
  <style>
    .container {
      margin: 20px;
      border: 1px solid black;
      padding: 20px;
      background-color: #ffc;
    }
    .demo {
      margin: 4px;
      border: 1px solid blue;
      padding: 4px;
      color: red;
      background-color: white;
      vertical-align: middle;
    }
  </style>
  <script src="../base.js"></script>
  <script>
    goog.require('goog.style');
  </script>
  <script>
    function inlineBlockify(tag, className, parentElement) {
      goog.array.forEach(
          goog.dom.getElementsByTagNameAndClass(tag, className, parentElement),
          function(el) {
            goog.style.setInlineBlock(el);
          });
    }

    function inlineBlockifyAll() {
      inlineBlockify('span', 'demo', goog.dom.getElement('foo'));
    }
  </script>
</head>
<body>
  <h1>goog.style.setInlineBlock in standards mode</h1>
  <p>
    This is a demonstration of the <code>goog-inline-block</code> CSS style.
    This page is in <strong>standards</strong> mode.
    <a href="inline_block_quirks.html">Click here for quirks mode.</a>
  </p>
  <div class="container">
    Hey, are these really
    <div class="demo goog-inline-block">DIV</div>s
    inlined in my text here?  I mean, I thought
    <div class="demo goog-inline-block">DIV</div>s
    were block-level elements, and you couldn't inline them...
    Must be that new
    <div class="demo goog-inline-block">goog-inline-block</div>
    style...  (Hint:  Try resizing the window to see the
    <div class="demo goog-inline-block">DIV</div>s
    flow naturally.)
    Arv asked for an inline-block DIV with more interesting contents, so here
    goes:
    <div class="demo goog-inline-block">
      <div style="width:320px;font-size:80%;">
        <img src="../images/gears_bluedot.gif" alt="blue dot"
             style="float:left; margin: 0 1em 1em 0;"/>
        Lorem ipsum dolor sit amet,
        consectetuer adipiscing elit.
        Donec rhoncus neque ut
        neque porta consequat.
        In tincidunt tellus vehicula tellus. Etiam ornare nunc
        vel lectus. Vivamus quis nibh. Sed nunc.
        <strong>On FF1.5 and FF2.0, you need to wrap the contents of your
          inline-block element in a DIV or P with fixed width to get line
          wrapping.</strong>
      </div>
    </div>
  </div>
  <div class="container">
    <p>
      These are
      <span class="demo goog-inline-block">SPAN</span>s
      with the
      <span class="demo goog-inline-block">goog-inline-block</span>
      style applied, so you can style them like block-level elements.
      For example, give them
      <span class="demo goog-inline-block" style="margin:10px;">10px margin</span>, a
      <span class="demo goog-inline-block" style="border-width:10px;">10px border</span>, or
      <span class="demo goog-inline-block" style="padding:10px;">10px padding</span>.
      I used
      <span class="demo goog-inline-block" style="">vertical-align: middle</span>
      to make them all line up reasonably well.
      (Except on Safari 2.  Go figure.)
    </p>
    <p>
      This is what the same content looks like <strong>without goog-inline-block</strong>:
    </p>
    <p id="foo">
      These are
      <span class="demo">SPAN</span>s
      with the
      <span class="demo">goog-inline-block</span>
      style applied, so you can style them like block-level elements.
      For example, give them
      <span class="demo" style="margin:10px;">10px margin</span>, a
      <span class="demo" style="border-width:10px;">10px border</span>, or
      <span class="demo" style="padding:10px;">10px padding</span>.
      I used
      <span class="demo" style="">vertical-align: middle</span>
      to make them all line up reasonably well.
      (Except on Safari 2.  Go figure.)
    </p>
    <p>
      <a href="#" onclick="inlineBlockifyAll();">Click here</a> to use <code>goog.style.setInlineBlock()</code> to apply the inline-block style to these SPANs.
    </p>
  </div>
  <p>
    Works on Internet Explorer 6 &amp; 7, Firefox 1.5, 2.0 &amp; 3.0 Beta, Safari 2 &amp; 3,
    Webkit nightlies, and Opera 9.
    <em><strong>Note:</strong> DIVs nested in SPANs don't work on Opera.</em>
  </p>
</body>
</html>