How do I stretch vertically mdl-cards so that everything is even out? I'd prefer the mdl-card__suporting-text
to be stretch.
Here's an example http://codepen.io/anon/pen/grGbdb
How do I stretch vertically mdl-cards so that everything is even out? I'd prefer the mdl-card__suporting-text
to be stretch.
Here's an example http://codepen.io/anon/pen/grGbdb
There are three problems to address.
First mdl-cell
elements have already the height of the "biggest" cell in the row.
Therefore to make the cards the same height "make the card to be cell".
<div class="mdl-cell mdl-card mdl-shadow--2dp demo-card-wide">
//...
</div>
The next problem would be that the mdl-card__actions
is not at the bottom of the card.
To change this make the actions position absolute and and move it to the bottom.
.demo-card-wide > .mdl-card__actions {
position: absolute;
bottom: 0px;
}
Third problem:
Now the content and the actions of the biggest cars are overlapping. This is the nasty one. There is only a easy solution (as I know) if you know the height of the actions. Then add a padding-bottom
to the card.
.demo-card-wide.mdl-card {
/* ... */
padding-bottom: 50px;
}
And one comment: Try to avoid the fix width of the card. Better use: mdl-cell--X-col/yyy/ from mdl grid
Look at this changed codepen
You can add an empty <div class="column-expander"></div>
at the point you want to add a spacer, and this to your css:
.column-expander {
flex-grow: 1;
}
All you need to do is put the card components inside a grid cell, like:
<div class="mdl-card-wide mdl-cell mdl-cell--N-col>
The mdl grid system has default spaces, so if you put a card component inside a cell, the card will automatically adopt the default grid space.
This is the codepen example:
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-phone mdl-shadow--4dp">
<div class="mdl-grid mdl-grid--no-spacing">
<div class="mdl-cell mdl-cell--6-col green">
</div>
<div class="mdl-card-wide mdl-cell mdl-cell--6-col mdl-shadow">
<div class="mdl-card__supporting-text">
<h4>Tablet</h4>
<p>Ni un solo pixel desaprovechado, el contenido de tu pagina se ajusta a todo.</p>
</div>
</div>
</div>
</div>
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-phone mdl-shadow--4dp">
<div class="mdl-grid mdl-grid--no-spacing">
<div class="mdl-cell mdl-cell--6-col green">
</div>
<div class="mdl-card-wide mdl-cell mdl-cell--6-col mdl-shadow">
<div class="mdl-card__supporting-text">
<h4>Tablet</h4>
<p>Ni un solo pixel desaprovechado, el contenido de tu pagina se ajusta a todo.</p>
</div>
</div>
</div>
</div>
<div class="mdl-cell mdl-cell--4-col mdl-cell--4-col-phone mdl-shadow--4dp">
<div class="mdl-grid mdl-grid--no-spacing">
<div class="mdl-cell mdl-cell--6-col green">
</div>
<div class="mdl-card-wide mdl-cell mdl-cell--6-col mdl-shadow">
<div class="mdl-card__supporting-text">
<h4>Tablet</h4>
<p>Ni un solo pixel desaprovechado, el contenido de tu pagina se ajusta a todo.</p>
</div>
</div>
</div>
</div>
</div>
Also remember this, card components can be square or wide, but if you put the card inside a cell, you will no need to write square or wide.
And avoid mdl demo components.