{"id":182130,"date":"2014-09-08T08:45:27","date_gmt":"2014-09-08T15:45:27","guid":{"rendered":"http:\/\/css-tricks.com\/?p=182130"},"modified":"2019-08-21T16:55:47","modified_gmt":"2019-08-21T23:55:47","slug":"glitch-effect-text-images-svg","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/glitch-effect-text-images-svg\/","title":{"rendered":"Glitch Effect on Text \/ Images \/ SVG"},"content":{"rendered":"

Lucas Bebber’s Glitch<\/a> is a super cool effect. It’s like you’re looking at some text displayed on a progressive scan monitor that has been dropped on the ground one too many times and so the alignment of the pixels is off in weirdly un-even amounts time and space.<\/p>\n

It’s bonafide CSS trick if there ever was one! It took me a bit to figure out how it was working, so I thought I’d explain. Then I ended up making it work for other kinds of content as well as making it into a group of Sass @mixin<\/code>s to make working with it a bit easier.<\/p>\n

<\/p>\n

\n See the Pen
\n CSS Glitched Text<\/a> by Chris Coyier (
@chriscoyier<\/a>)
\n on
CodePen<\/a>.<\/span>\n<\/p>\n

Three Copies of the Text<\/h3>\n

While the HTML is just:<\/p>\n

<div class=\"glitch\" data-text=\"GLITCH\">GLITCH<\/div> <\/code><\/pre>\n

Three copies of it are created, via pseudo-elements, and they are positioned right on top of each other.<\/p>\n

.glitch {\r\n  position: relative;\r\n}\r\n.glitch::before,\r\n.glitch::after {\r\n  content: attr(data-text);\r\n  position: absolute;\r\n  top: 0;\r\n  left: 0;\r\n  width: 100%;\r\n  height: 100%;\r\n}<\/code><\/pre>\n

Producing three unique copies that can be controlled individually:<\/p>\n

<\/figure>\n

Alter the Copies<\/h3>\n

Each copy is identical except that:<\/p>\n