Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/html/lib/onyx/design/inline-controlled.html
blob: b233d191f7996f51da397fb909e0464c985c0417 (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!doctype html>
<html>
<head>
	<title>controlled inline: onyx toolbar design</title>
	<link href="../source/css/onyx.css" rel="stylesheet" type="text/css" />
	<style>
		/*
			the 'inline' class sets up a left-to-right container, with vertically centered children
		*/
		.inline {
			white-space: nowrap;
		}
		.inline > * { 
			display: inline-block;
			vertical-align: middle;
		}
		.icon {
			width: 32px;
			height: 32px;
			background-image: url(menu-icon-bookmark.png);
		}
		.bord {
			border: 1px solid lightblue;
		}
		.big {
			font-size: 48px;
		}
		.pad {
			padding: 8px;
		}
		.bg {
			background: orange;
		}
		/*
			We can control line-height so that vertical-align: middle 
			becomes true center. Otherwise, when line-height is in effect
			(i.e. if the actual height is less than line height), 
			user agents pad the line unevenly.
		*/
		.lhc {
			line-height: 0;
		}
		/*
			Defeat line-height control above for children
		*/
		.lhc > * {
			line-height: normal;
		}
		/*
			Enforce line-height 0 for an inline child of an inline (FIXME: fiddly)
		*/
		.lhc .lhc {
			line-height: 0px;
		}
		/**/
		.h {
			height: 64px;
		}
		/*
			It's useful to be able to abut toolbars in an inline context
			and not worry about varying heights.
			Generally icons are the largest elements in a toolbar, and will
			drive the height to this size.
			We can't set a min-size directly on the toolbar because it
			breaks centering (due to interation with line-height).
			For some scenarios a developer may want to override the height value.
		*/
		.stent {
			/*
				the point of the stent is to force the box height to some minimum, similar
				to line-height, but with proper vertical centering
			*/
			height: 72px;
			/* the width is 0, but it adds some size to the inline because of ? */
			width: 0px;
			visibility: hidden;
		}
		.stent-fix {
			/* stent imparts mystery width to it's parent */
			/* setting font-size doesn't affect the mystery width */
			/*font-size: 0px;*/
			/* floating the stent prevents it from stenting */
			/*float: left;*/
			/* on non-mozilla, mystery size can be removed this way, but the actual pixels needed depends on font size */
			/*margin-right: -6px;*/
			/* on non-mozilla, this gets us within a few pixels for tested fonts */
			margin-right: -0.25em;
		}
		/* */
		.stenty > * {
			min-height: 56px;
		}
	</style>
</head>
<body>
	<label>"inline" tests</label>
	<br /><br />

	<div>
		<label>combo content: when the text is larger than non-text objects, vertical centering goes wonky</label>
		<div class="inline bord big">
			<div>Text in Div</div>
			<input />
			<div class="icon"></div>
		</div>
		<br />

		<label>... it's possible to control line-height in such a way to repair centering</label>
		<div class="inline bord big lhc">
			<div>Text in Div</div>
			<input />
			<div class="icon"></div>
		</div>
		<br />

		<hr />

		<label>but now setting height or min-height on toolbar breaks centering</label>
		<div class="inline bord lhc bg big h">
			<div>Text in Div</div>
			<input />
			<div class="icon"></div>
		</div>
		<br />

		<div class="inline bord big lhc">
			<div class="inline bord lhc bg h">
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg h">
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />

		<hr />

		<label>control height on children instead of toolbar</label>
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg">
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg">
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg stenty">
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg stenty">
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />

		<hr />

		<label>it's possible to use a stent to effect min-height, but for unknown reasons, even a 0-width stent affects parent width</label>
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg">
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg">
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg">
				<div class="stent"></div>
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg">
				<div class="stent"></div>
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />

		<label>using img as stent node makes no difference</label>
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg">
				<img class="stent" />
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg">
				<img class="stent" />
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />

		<label>using negative margin on stent can approximate 0 width</label>
		<div class="inline bord big lhc">
			<div class="inline bord lhc bg">
				<div class="stent stent-fix"></div>
				<div>Text in Div</div>
				<input />
				<div class="icon"></div>
			</div>
			<div class="inline bord lhc bg">
				<div class="stent stent-fix"></div>
				<input />
				<div class="icon"></div>
			</div>
		</div>
		<br />
	</div>
</body>
</html>