Skip to content

Commit 46a5d95

Browse files
author
Jeff Escalante
committed
Merge pull request #200 from jenius/table-layout
adds table-layout
2 parents 4dd9379 + ed6d66e commit 46a5d95

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

axis/layout.styl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,22 @@ ratio-box(ratio = 1/1)
112112
display: block
113113
height: 0
114114
padding-top: (1 / ratio) * 100%
115+
116+
117+
// Mixin: Table Layout
118+
//
119+
// Sometimes you just need a good old-fashioned table layout.
120+
// Read more: http://colintoh.com/blog/display-table-anti-hero
121+
//
122+
// ex: tl()
123+
// ex: tl(auto)
124+
125+
tl(layoutType = fixed)
126+
display: table
127+
table-layout: layoutType // "fixed" or "auto"
128+
margin: 0
129+
padding: 0
130+
width: 100%
131+
132+
> *
133+
display: table-cell
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.tl {
2+
display: table;
3+
table-layout: fixed;
4+
margin: 0;
5+
padding: 0;
6+
width: 100%;
7+
}
8+
.tl > * {
9+
display: table-cell;
10+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.tl
2+
tl()

test/test.coffee

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ describe 'layout', ->
167167
it 'vertical-align', (done) ->
168168
compile_and_match(path.join(@path, 'vertical-align.styl'), done)
169169

170+
it 'table-layout', (done) ->
171+
compile_and_match(path.join(@path, 'table-layout.styl'), done)
172+
170173
describe 'print', ->
171174

172175
before -> @path = path.join(test_path, 'print')

test/visual.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<link rel='stylesheet' href='fixtures/layout/media.css' >
5050
<link rel='stylesheet' href='fixtures/layout/ratio-box.css' >
5151
<link rel='stylesheet' href='fixtures/layout/vertical-align.css' >
52+
<link rel='stylesheet' href='fixtures/layout/table-layout.css' >
5253

5354
<!-- tables -->
5455
<link rel='stylesheet' href='fixtures/tables/table.css' >
@@ -256,6 +257,14 @@ <h1>layout</h1>
256257
<div class='inner-div reset'>not vertically aligned</div>
257258
</div>
258259

260+
<ul class="tl">
261+
<li>
262+
<h1>Table Layout Mixin</h1>Adding more lines here.<br/>Will add height<br/>to the li's to the right.
263+
</li>
264+
<li>2</li>
265+
<li>3</li>
266+
<li>4</li>
267+
</ul>
259268
</section>
260269

261270
<section id='tables'>

0 commit comments

Comments
 (0)