- <html>
- <head>
- <title>CSS to JavaScript</title>
- <script type="text/javascript">
- </script>
- <style type="text/css">
- </style>
- </head>
- <body>
- <script type="text/javascript">
- (function() {
- var d = document,
- DOMParentElement = function(e, id) {
- this.element = d.body.appendChild(d.createElement(e));
- this.element.id = id;
- this.accessElement = function() {
- return this.element;
- };
- };
- Object.prototype.append = function(e, id) {
- var el = this.appendChild(d.createElement(e));
- el.id = id;
- };
- var respectiveStyle = ["background-color", "color", "font-family", "font-size", "position", "left", "right", "top", "bottom", "margin-left", "margin-right", "margin-top", "margin-bottom", "width", "height"],
- mainHeader = new DOMParentElement("DIV", "main_header");
- mainHeader.accessElement().append("DIV", "container");
- var container = document.getElementById("container");
- container.append("SPAN", "text-first-half");
- container.append("SPAN", "text-second-half");
- var textFH = document.getElementById("text-first-half"),
- textSH = document.getElementById("text-second-half");
- textFH.textContent = "Co";
- textSH.textContent = "ol";
- var allHTMLElements = document.getElementsByTagName("*");
- for (var i = 0; i < allHTMLElements.length; i++) {
- allHTMLElements[i].style.padding = 0;
- allHTMLElements[i].style.margin = 0;
- }
- for (var i = 0; i < respectiveStyle.length; i++) {
- mainHeader.accessElement().style[respectiveStyle[i]] = ["#666666", false, "Tahoma"][i];
- container.style[respectiveStyle[i]] = ["#9E9E9E", false, false, "100px", false, false, false, false, false, "1px", "1px", "1px", false, "50%", "10em"][i];
- textFH.style[respectiveStyle[i]] = [false, "#ffffff", mainHeader.accessElement().style.fontFamily, false, "absolute", "515px", false, false, "350px"][i];
- textSH.style[respectiveStyle[i]] = [false, "#000000", mainHeader.accessElement().style.fontFamily, false, "absolute", "635px", false, false, "350px"][i];
- }
- })();
- </script>
- </body>
- </html>