| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 * { | |
| 2 box-sizing: border-box; | |
| 3 } | |
| 4 | |
| 5 body { | |
| 6 background: grey; | |
| 7 padding: 0; | |
| 8 margin: 0; | |
| 9 } | |
| 10 | |
| 11 h2 { | |
| 12 font-size: 30px; | |
| 13 } | |
| 14 | |
| 15 p { | |
| 16 margin: 0 0 10px; | |
| 17 padding: 0; | |
| 18 } | |
| 19 | |
| 20 .card-group { | |
| 21 padding: 30px; | |
| 22 } | |
| 23 | |
| 24 .card { | |
| 25 background: #fff; | |
| 26 border: 1px solid black; | |
| 27 } | |
| 28 | |
| 29 | |
| 30 // Note: With both solutions, I use a fixed header height | |
| 31 $card__header--height: 100px; | |
|
juliandoucette
2017/05/23 11:52:00
This is not ideal. We have a problem with long hea
ire
2017/05/23 17:21:44
Noted. I'm not sure, but there may be a way with G
| |
| 32 | |
| 33 .card__header { | |
| 34 height: $card__header--height; | |
| 35 margin-bottom: 20px; | |
| 36 border: 2px solid plum; | |
| 37 } | |
| 38 | |
| 39 .card__content { | |
| 40 border: 2px solid cornflowerblue; | |
| 41 } | |
| 42 .card__footer { | |
| 43 border: 2px solid lightcoral; | |
| 44 } | |
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 /* Table Layout Fallback | |
| 50 * Note - requires a set height for the .card__footer | |
| 51 */ | |
| 52 | |
| 53 $card__footer--height: 30px; | |
|
ire
2017/05/19 05:37:57
@julian Here is the main difference between the tw
juliandoucette
2017/05/23 11:52:00
Acknowledged.
I think this is a reasonable limita
ire
2017/05/23 17:21:44
Acknowledged.
| |
| 54 | |
| 55 .card-group { | |
| 56 display: table; | |
| 57 } | |
| 58 | |
| 59 .card { | |
| 60 display: table-cell; | |
| 61 position: relative; | |
| 62 | |
| 63 width: 100%; | |
| 64 @media (min-width: 600px) { width: 50%; } | |
| 65 @media (min-width: 800px) { width: 33%; } | |
|
ire
2017/05/19 05:37:57
@julian Another difference is that the breakpoints
juliandoucette
2017/05/23 11:52:00
Acknowledged.
This doesn't resize well :(
Ideall
ire
2017/05/23 17:21:44
On 2017/05/23 11:52:00, juliandoucette wrote:
| |
| 66 } | |
| 67 | |
| 68 .card__content { | |
| 69 margin-bottom: $card__footer--height + 20px; | |
| 70 } | |
| 71 | |
| 72 .card__footer { | |
| 73 height: $card__footer--height; | |
| 74 width: 100%; | |
| 75 position: absolute; | |
| 76 left: 0; | |
| 77 bottom: 0; | |
| 78 } | |
| 79 | |
| 80 | |
| 81 | |
| 82 /* Grid Layout Enhancement | |
| 83 * | |
| 84 */ | |
| 85 $card--max-width: 300px; | |
| 86 | |
| 87 @supports (display: grid) { | |
| 88 | |
| 89 .card-group { | |
| 90 display: grid; | |
| 91 grid-template-columns: repeat(auto-fit, minmax($card--max-width, 1fr)) | |
| 92 } | |
| 93 | |
| 94 .card { | |
| 95 display: inline-grid; | |
| 96 grid-template-rows: minmax($card__header--height, auto) 1fr auto; | |
| 97 @media all { width: 100%; } | |
| 98 } | |
| 99 | |
| 100 .card__content { | |
| 101 margin-bottom: 20px; | |
| 102 } | |
| 103 | |
| 104 .card__footer { | |
| 105 position: relative; | |
| 106 height: auto; | |
| 107 } | |
| 108 | |
| 109 } | |
| OLD | NEW |