Skip to content

Instantly share code, notes, and snippets.

@ChrisBAshton
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisBAshton/80e90dcf0acf30a5b02b to your computer and use it in GitHub Desktop.
Save ChrisBAshton/80e90dcf0acf30a5b02b to your computer and use it in GitHub Desktop.
.alignleft {
float: left;
}
.longtext {
@text (length < 300) {
overflow: hidden;
}
}
.longtext {
overflow: min-words 5;
}
/*
<img class="alignleft" src="some_src.png" /> <p class="longtext">This is my accompanying text.</p>
*/
@ChrisBAshton
Copy link
Author

If the text is long enough, I want it to overflow under the image. But if the text is a bit short, it's silly to have it overflow under the image if, say, only one word will flow underneath. This CSS proposal tries to fix the issue.

I've proposed two different ways of achieving this - one is a new meta wrapper like a media query, and the other is a new allowed value for 'overflow'.

The first will only overflow if the text length is a minimum of 300 characters. The second implementation will only overflow if the text is long enough that at least 5 words will flow underneath.

Yes, this could be achieved in JavaScript - but once again, I feel this is presentation logic and should be encompassed in CSS.

See css-dom-position.css for another CSS proposal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment