Browse files

[Compass Core] Cross browser ellipsis mixin.

Since this requires the installation of an additional xml file for
firefox support, it is provided as a pattern.

To install:
compass -p ellipsis

To use:
Mix +ellipsis into a selector targeting the textual element that will
truncate via ellipsis. By default, ellipsis text is set tono-wrap. Pass
false as the first argument if you don't want that.

Firefox is the lame browser in this respect, it requires a lot of bending
over backwards and has many quirky behaviors. Please read the blog post at for a full
explanation of the issues. Also note that ellipsis text is white-space
sensitive in Firefox, an issue that is sure to affect Haml users more than
  • Loading branch information...
chriseppstein committed Jul 4, 2009
1 parent ff5c850 commit 3d909ceda997bdcde2aec09bd72e646098389e7d
@@ -3,6 +3,7 @@
@import yui/modules/base.sass
@import blueprint/modules/grid.sass
@import blueprint/modules/scaffolding.sass
@import compass/utilities/text/ellipsis.sass
@@ -67,6 +68,12 @@ h2
+outer-table-borders(2px, #151A99)
+inner-table-borders(1px, #151A99)
+column(8, true)
width: 50%
@@ -139,6 +139,10 @@
%td.numeric.even 15.5
%td.numeric.odd 16.0
%td.numeric.even 17.5
%h2 Ellipsis
%p This long text is truncated at the end of the first line. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
%h2 Floats
@@ -0,0 +1,13 @@
This technique, by [Justin Maxwell](, was originally
published at
Firefox implementation by [Rikkert Koppes](
=ellipsis(!no_wrap = true)
@if !no_wrap
white-space: nowrap
overflow: hidden
text-overflow: ellipsis
-o-text-overflow: ellipsis
-ms-text-overflow: ellipsis
-moz-binding= stylesheet_url("xml/ellipsis.xml#ellipsis")
@@ -0,0 +1,6 @@
@import compass/utilities/text/ellipsis.sass
// You can delete this sass file if you want, it's just an example of how to use the ellipsis mixin.
// By default, ellipsis text is no-wrap. Pass false as the first argument if you don't want that.
@@ -0,0 +1,2 @@
file 'xml/ellipsis.xml', :like => :css
stylesheet 'ellipsis.sass'
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<binding id="ellipsis">
<xul:description crop="end" xbl:inherits="value=xbl:text"><children/></xul:description>

0 comments on commit 3d909ce

Please sign in to comment.