Created
February 6, 2014 07:11
-
-
Save robdodson/8839578 to your computer and use it in GitHub Desktop.
responsive table styles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Polymer('polymer-table', { | |
ready: function () { | |
var css = []; | |
var style = document.createElement('style'); | |
var nodeList = this.$.header.getDistributedNodes(); | |
var thList = nodeList[0].children[0].children; | |
[].forEach.call(thList, function (th, i) { | |
css.push( | |
':host.mobile td:nth-of-type('+(i + 1)+'):before {'+ | |
'content: "'+th.textContent+'";'+ | |
'}' | |
); | |
}); | |
css = css.join('\n'); | |
if (style.styleSheet) { | |
style.styleSheet.cssText = css; | |
} else { | |
style.appendChild(document.createTextNode(css)); | |
} | |
document.head.appendChild(style); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment