Turns a standard list into a block list; very useful for touch interfaces. Improvements welcome.
-
-
Save zapatoche/3954650 to your computer and use it in GitHub Desktop.
A Sass mixin for block lists.
This file contains hidden or 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
<ul class="block-list"> | |
<li> | |
Foo | |
</li> | |
<li> | |
<a href="#">Bar</a> | |
</li> | |
<li> | |
<a href="#">Baz</a> | |
</li> | |
</ul> |
This file contains hidden or 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
.block-list { | |
border-top: 1px solid #cccccc; | |
list-style: none; | |
padding-left: 0; | |
} | |
.block-list > li { | |
border-bottom: 1px solid #cccccc; | |
list-style-image: none; | |
list-style-type: none; | |
margin-left: 0; | |
padding: 0.75em; | |
} | |
.block-list > li a { | |
display: block; | |
padding: 0.75em; | |
margin: -0.75em; | |
} |
This file contains hidden or 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
// Block List of Content | |
// | |
// Turns a standard list into a block list; very useful for touch interfaces. | |
// | |
// Inspired by inuit.css https://github.com/csswizardry/inuit.css | |
// | |
// Arguments accepted: | |
// $selector - optionally configure block link selectors | |
// $border-color - color of border | |
// $border-bottom-width - size of bottom border | |
// $item-padding - a single value for space around the item | |
// | |
// Browser Compatibility: | |
// IE7+: This is a progressive enhancement mixin, | |
// block links are not 100% width in IE7. | |
@mixin block-list($link-selector: 'a', $border-color: #ccc, $border-width: 1px, $item-padding: 0.75em) { | |
border-top: $border-width solid $border-color; | |
list-style: none; | |
padding-left: 0; | |
> li { | |
border-bottom: $border-width solid $border-color; | |
list-style-image: none; | |
list-style-type: none; | |
margin-left: 0; | |
padding: $item-padding; | |
#{$link-selector} { | |
display: block; | |
padding: $item-padding; | |
margin: -$item-padding; | |
} | |
} | |
} | |
// Standard usage | |
.block-list { | |
@include block-list; | |
} | |
// Using a custom selector for a block link | |
// .block-list-alt { | |
// @include block-list('.block-list__link'); | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment