Skip to content

Instantly share code, notes, and snippets.

@robdodson
Created February 6, 2014 07:11
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 robdodson/8839578 to your computer and use it in GitHub Desktop.
Save robdodson/8839578 to your computer and use it in GitHub Desktop.
responsive table styles
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