Hyperminimal CSS flexbox grid & micro layout alternative
Github npmA fundamentally different approach to handling layout in CSS
Instead of adding up columns, .x is based around content sizes and dividing up available space, which makes it perfect for responsive web design. No clearfix, white space, or display table hacks – just a simple abstraction of the flexible layout module.
Apply .x to a parent container to align items on the x-axis.
<div class="x">
<div class="p2">auto</div>
<div class="p2">auto</div>
</div>
Add .xg to make a child element grow to fill the space.
flex grow
auto
<div class="x">
<div class="xg p2">
<h2>.xg</h2>
<p>flex grow</p>
</div>
<div class="p2">
<p>auto</p>
</div>
</div>
flex grow
flex grow
<div class="x">
<div class="xg p2">
<h2>.xg</h2>
<p>flex grow</p>
</div>
<div class="xg p2">
<h2>.xg</h2>
<p>flex grow</p>
</div>
</div>
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
flex none
<div class="x">
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
<div class="xn p2">
<h2>.xn</h2>
<p>flex none</p>
</div>
</div>
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x x-center">
<div class="p2">
<h2>align-items center</h2>
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
<div class="xn p2">
<h2>.xn</h2>
</div>
</div>
<div class="x x-baseline">
<div class="xg p2">
<h1 class="border-bottom border-aqua">align-items baseline</h1>
</div>
<div class="xn p2">
<h2 class="border-bottom border-aqua">.xn</h2>
</div>
</div>
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x x-bottom">
<div class="p2">
<h2>align-items flex-end</h2>
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
<div class="xn p2">
<h2>.xn</h2>
</div>
</div>
1/2 width
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x">
<div class="x2 p2">
<h2>.x2</h2>
<p>1/2 width</p>
</div>
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
</div>
1/2 width
1/2 width
<div class="x">
<div class="x2 p2">
<h2>.x2</h2>
<p>1/2 width</p>
</div>
<div class="x2 p2">
<h2>.x2</h2>
<p>1/2 width</p>
</div>
</div>
1/3 width
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x">
<div class="x3 p2">
<h2>.x3</h2>
<p>1/3 width</p>
</div>
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
</div>
1/3 width
1/3 width
1/3 width
<div class="x">
<div class="x3 p2">
<h2>.x3</h2>
<p>1/3 width</p>
</div>
<div class="x3 p2">
<h2>.x3</h2>
<p>1/3 width</p>
</div>
<div class="x3 p2">
<h2>.x3</h2>
<p>1/3 width</p>
</div>
</div>
1/4 width
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x">
<div class="x4 p2">
<h2>.x4</h2>
<p>1/4 width</p>
</div>
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
</div>
1/4 width
1/4 width
1/4 width
1/4 width
<div class="x">
<div class="x4 p2">
<h2>.x4</h2>
<p>1/4 width</p>
</div>
<div class="x4 p2">
<h2>.x4</h2>
<p>1/4 width</p>
</div>
<div class="x4 p2">
<h2>.x4</h2>
<p>1/4 width</p>
</div>
<div class="x4 p2">
<h2>.x4</h2>
<p>1/4 width</p>
</div>
</div>
1/6 width
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x">
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
</div>
1/6 width
1/6 width
1/6 width
1/6 width
1/6 width
1/6 width
<div class="x">
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
<div class="x6 p2">
<h2>.x6</h2>
<p>1/6 width</p>
</div>
</div>
1/8 width
Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.
<div class="x">
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="p2">
<p>Bacon ipsum dolor sit amet chuck prosciutto landjaeger ham hock filet mignon shoulder hamburger pig venison. Ham bacon corned beef, sausage kielbasa flank tongue pig drumstick capicola swine short loin ham hock kevin. Bacon t-bone hamburger turkey capicola rump short loin. Drumstick pork fatback pork chop doner pork belly prosciutto pastrami sausage. Ground round prosciutto shank pastrami corned beef venison tail. Turkey short loin tenderloin jerky porchetta pork loin.</p>
</div>
</div>
1/8 width
1/8 width
1/8 width
1/8 width
1/8 width
1/8 width
1/8 width
1/8 width
<div class="x">
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
<div class="x8 p2">
<h2>.x8</h2>
<p>1/8 width</p>
</div>
</div>
<div class="x x-wrap">
<div class="x2 p2">.x2</div>
<div class="x2 p2">.x2</div>
<div class="x2 p2">.x2</div>
<div class="x2 p2">.x2</div>
<div class="x2 p2">.x2</div>
<div class="x2 p2">.x2</div>
</div>
<div class="x x-justify">
<div class="x4 p2">.x4</div>
<div class="x4 p2">.x4</div>
<div class="x4 p2">.x4</div>
</div>
<div class="x x-wrap">
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
<div class="xs p2">.xs</div>
</div>
<div class="overflow-auto">
<div class="x xx-wrap">
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
<div class="xm p2">.xm</div>
</div>
</div>
<div class="x x-wrap">
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
<div class="xl p2">.xl</div>
</div>
*, *:before, *:after { box-sizing: border-box }
.x { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex }
.x1 { -webkit-box-flex: 0; -webkit-flex: 0 0 100%; -ms-flex: 0 0 100%; flex: 0 0 100% }
.x2 { -webkit-box-flex: 0; -webkit-flex: 0 0 50%; -ms-flex: 0 0 50%; flex: 0 0 50% }
.x3 { -webkit-box-flex: 0; -webkit-flex: 0 0 33.33333%; -ms-flex: 0 0 33.33333%; flex: 0 0 33.33333% }
.x4 { -webkit-box-flex: 0; -webkit-flex: 0 0 25%; -ms-flex: 0 0 25%; flex: 0 0 25% }
.x6 { -webkit-box-flex: 0; -webkit-flex: 0 0 16.66667%; -ms-flex: 0 0 16.66667%; flex: 0 0 16.66667% }
.x8 { -webkit-box-flex: 0; -webkit-flex: 0 0 12.5%; -ms-flex: 0 0 12.5%; flex: 0 0 12.5% }
.xs { -webkit-box-flex: 0; -webkit-flex: 0 0 25%; -ms-flex: 0 0 25%; flex: 0 0 25% }
.xm { -webkit-box-flex: 0; -webkit-flex: 0 0 50%; -ms-flex: 0 0 50%; flex: 0 0 50% }
.xl { -webkit-box-flex: 0; -webkit-flex: 0 0 100%; -ms-flex: 0 0 100%; flex: 0 0 100% }
.xg { -webkit-box-flex: 1; -webkit-flex: 1 0 auto; -ms-flex: 1 0 auto; flex: 1 0 auto }
.xn { -webkit-box-flex: 0; -webkit-flex: none; -ms-flex: none; flex: none }
.x-center { -webkit-box-align: center; -webkit-align-items: center; -ms-flex-align: center; align-items: center }
.x-baseline { -webkit-box-align: baseline; -webkit-align-items: baseline; -ms-flex-align: baseline; align-items: baseline }
.x-bottom { -webkit-box-align: end; -webkit-align-items: flex-end; -ms-flex-align: end; align-items: flex-end }
.x-wrap { -webkit-flex-wrap: wrap; -ms-flex-wrap: wrap; flex-wrap: wrap }
.x-justify { -webkit-box-pack: justify; -webkit-justify-content: space-between; -ms-flex-pack: justify; justify-content: space-between }
@media (min-width: 40em) {
.sm-x { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex }
.xs { -webkit-box-flex: 0; -webkit-flex: 0 0 16.66667%; -ms-flex: 0 0 16.66667%; flex: 0 0 16.66667% }
.xm { -webkit-box-flex: 0; -webkit-flex: 0 0 33.33333%; -ms-flex: 0 0 33.33333%; flex: 0 0 33.33333% }
.xl { -webkit-box-flex: 0; -webkit-flex: 0 0 50%; -ms-flex: 0 0 50%; flex: 0 0 50% }
}
@media (min-width: 52em) {
.md-x { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex }
.xs { -webkit-box-flex: 0; -webkit-flex: 0 0 12.5%; -ms-flex: 0 0 12.5%; flex: 0 0 12.5% }
.xm { -webkit-box-flex: 0; -webkit-flex: 0 0 25%; -ms-flex: 0 0 25%; flex: 0 0 25% }
.xl { -webkit-box-flex: 0; -webkit-flex: 0 0 33.33333%; -ms-flex: 0 0 33.33333%; flex: 0 0 33.33333% }
}
@media (min-width: 64em) {
.lg-x { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; display: flex }
.xs { -webkit-box-flex: 0; -webkit-flex: 0 0 8.33333%; -ms-flex: 0 0 8.33333%; flex: 0 0 8.33333% }
.xm { -webkit-box-flex: 0; -webkit-flex: 0 0 16.66667%; -ms-flex: 0 0 16.66667%; flex: 0 0 16.66667% }
.xl { -webkit-box-flex: 0; -webkit-flex: 0 0 25%; -ms-flex: 0 0 25%; flex: 0 0 25% }
}