Skip to content

Commit 47522cf

Browse files
committed
[css3-box] Added the idea to use float & float-offset for vertically
centering.
1 parent 03083ca commit 47522cf

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

css-box/Overview.src.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,22 @@ <h2 class="no-toc no-num">Status of this document</h2>
322322

323323
<p>This cannot top-align the first child and bottom-align
324324
the second.
325+
326+
<li>
327+
<p>Vertically centering a single element could also be
328+
modeled as a float with an offset. A draft of
329+
[[CSS-PAGE-FLOATS]] from 2013 suggests the following to
330+
center a P vertically inside its parent DIV:
331+
332+
<pre>DIV {height: 15em;
333+
colums: 1} /* Make the DIV act like a "page" */
334+
P {float: top left; /* Place the P in the corner of the DIV... */
335+
float-offset: 0 50%} /* ... and add 50% offset vertically */</pre>
336+
337+
<p>Floats like this also allow to put all children at the
338+
top and the last child against the bottom. But only one
339+
child: trying to push multiple children down to the bottom
340+
results in their order being reversed.
325341
</ol>
326342
</div>
327343

0 commit comments

Comments
 (0)