-
-
Save billerickson/c8e47e61fff3fc0d8cab61001ace6d37 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Column Classes | |
* | |
* Adds "-first" classes when appropriate for clearing float | |
* @see /assets/scss/partials/layout.scss | |
* | |
* @param array $classes, bootstrap-style classes, ex: array( 'col-lg-4', 'col-md-6' ) | |
* @param int $current, current post in loop | |
* @param bool $join, whether to join classes (return string) or return array | |
* @return array/string $classes | |
*/ | |
function ea_column_class( $classes = array(), $current = false, $join = true ) { | |
if( false === $current ) | |
return $classes; | |
$columns = array( 2, 3, 4, 6 ); | |
foreach( $columns as $column ) { | |
if( 0 == $current % $column ) { | |
$col = 12 / $column; | |
foreach( $classes as $class ) { | |
if( false != strstr( $class, (string) $col ) && false == strstr( $class, '12' ) ) { | |
$classes[] = str_replace( $col, 'first', $class ); | |
} | |
} | |
} | |
} | |
if( $join ) { | |
return join( ' ', $classes ); | |
} else { | |
return $classes; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@include media(">=tablet", "<medium") { | |
.col-sm-first { | |
clear: both; | |
} | |
} | |
@include media(">=medium", "<large") { | |
.col-md-first { | |
clear: both; | |
} | |
} | |
@include media(">=large") { | |
.col-lg-first { | |
clear: both; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment