x-layout
An <x-layout>
is simple layout element that automatically stretches content to fill the parent element, with optional toggleable header and footer elements.
Essentially, this is a simple flexboxed component used to fill a phone's screen or some other parent element. (By default, the layout attempts to be 100% width and height of its parent element, but this can be overridden.)
Due to using CSS flexbox, this component is not compatible with IE9 or below.
Basic usage
The structure of the <x-layout>
should consist of an (optional) <header>
, a <section>
to act as the main content, and an (optional) <footer>
.
(I will automatically overflow if necessary.)
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Markup
<x-layout>
<header>
I'm the header!
</header>
<section>
I'm the main body! <p>(I will automatically overflow if necessary.)</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p>
</section>
<footer>
I'm the footer!
</footer>
</x-layout>
CSS styling
x-layout > header, x-layout > footer{
padding: 0;
background-color: orange;
color: white;
font-weight: bold;
text-align: center;
}
Maximizing content with maxcontent
The header and footer of the <x-layout>
can minimized by applying the maxcontent
attribute.
(I will automatically overflow if necessary.)
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Markup
<x-layout>
<header>
I'm the header!
</header>
<section>
I'm the main body! <p>(I will automatically overflow if necessary.)</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p>
</section>
<footer>
I'm the footer!
</footer>
</x-layout>
Auto-maximizing content with hide-trigger
The header and footer of the <x-layout>
can hidden in response to various user interactions using the hide-trigger
attribute and its three options: tap
, hover
, and scroll
.
(I will automatically overflow if necessary.)
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Filler text
Markup
<x-layout>
<header>
I'm the header!
</header>
<section>
I'm the main body! <p>(I will automatically overflow if necessary.)</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p><p>Filler text</p>
</section>
<footer>
I'm the footer!
</footer>
</x-layout>