Skip to content

Instantly share code, notes, and snippets.

@sheodox
Created October 30, 2014 14:09
Show Gist options
  • Save sheodox/701971be4a750d2d64c3 to your computer and use it in GitHub Desktop.
Save sheodox/701971be4a750d2d64c3 to your computer and use it in GitHub Desktop.
Shadow DOM dialog. Putting this here to use later as a dialog for my specific dialog needs for a dialog that won't be effected by site styling.
(function() {
var dialog = document.createElement('div'),
shadow = dialog.createShadowRoot(),
style = document.createElement('style'),
paragraph = document.createElement('p');
dialog.style.width = '500px';
dialog.style.height = '500px';
dialog.style.border = '3px solid gray';
dialog.style.position = 'fixed';
dialog.style.top = window.screen.availHeight / 2 - 300 + 'px';
dialog.style.left = window.screen.availWidth / 2 - 300 + 'px';
dialog.style.background = 'white';
dialog.style.padding = '30px';
style.textContent = 'p{font-size:2em;color:blue;}';
paragraph.textContent = 'this is a shadow paragraph!';
shadow.appendChild(style);
shadow.appendChild(paragraph);
document.body.appendChild(dialog);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment