Truncation mixin

by Jens Grochtdreis

HTML

<h1 class=foo>This is some text that will truncate</h1>

<p class=bar>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>

SCSS

/**
 * Force overly long spans of text to truncate, e.g.:
 * 
   `@include truncate(100%);`
 * 
 * Where `$truncation-boundary` is a united measurement.
 */
@mixin truncate($truncation-boundary){
    max-width:$truncation-boundary;
    white-space:nowrap;
    overflow:hidden;
    text-overflow:ellipsis;
}



.foo{
    @include truncate(300px);
}
.bar{
    @include truncate(100%);
}































































html{
    font-size:1em;
    line-height:1.5;
    font-family:Georgia, serif;
}