Skip to content

Instantly share code, notes, and snippets.

Created April 24, 2012 17:55
  • Star 21 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
CSS Media Check
<!doctype html>
<title>CSS Media Check</title>
<style type="text/css">
-webkit-transition: width .001s;
-moz-transition: width .001s;
-ms-transition: width .001s;
-o-transition: width .001s;
transition: width .001s;
#mediaquery:after {
content: "small";
display: none;
@media all and (min-width: 10px) {
#mediaquery {
width: 50px;
#mediaquery:after {
content: "small";
@media all and (min-width: 600px) {
width: 100px;
#mediaquery:after {
content: "medium";
@media all and (min-width: 800px) {
width: 200px;
#mediaquery:after {
content: "large";
<body><div id="mediaquery"></div>
var mq = document.getElementById("mediaquery");
function eventCheck() {
// Check for all browsers
mq.addEventListener('webkitTransitionEnd', eventCheck, true);
mq.addEventListener('MSTransitionEnd', eventCheck, true);
mq.addEventListener('oTransitionEnd', eventCheck, true);
mq.addEventListener('transitionend', eventCheck, true);
Copy link

peter-m commented Oct 21, 2012

I wouldn't animate a pseudo element, as browser support is pretty unstable (see Chris' table on this topic and the according webkit bug report) - furthermore is there a particular reason why you exclude mozTransitionEnd?

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