]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Add grid-layout-center-last() mixin to center last items in block grid, closes #7807
authorGeoff Kimball <geoff@zurb.com>
Fri, 15 Jan 2016 01:28:01 +0000 (17:28 -0800)
committerGeoff Kimball <geoff@zurb.com>
Fri, 15 Jan 2016 01:28:01 +0000 (17:28 -0800)
scss/grid/_layout.scss

index e88d8cd87b6c59493f69d0ec5d7cbaadd9675f76..9f5da07c2c23b6687fff3ada6bba20d4bc56f278 100644 (file)
     }
   }
 }
+
+/// Adds extra CSS to block grid children so the last items in the row center automatically. Apply this to the columns, not the row.
+///
+/// @param {Number} $n - Number of items that appear in each row.
+@mixin grid-layout-center-last($n) {
+  @for $i from 1 to $n {
+    @if $i == 1 {
+      &:nth-child(#{$n}n+1):last-child {
+        margin-left: (100 - 100/$n * $i) / 2 * 1%;
+      }
+    }
+    @else {
+      &:nth-child(#{$n}n+1):nth-last-child(#{$i}) {
+        margin-left: (100 - 100/$n * $i) / 2 * 1%;
+      }
+    }
+  }
+}