forum

Home / DeveloperSection / Forums / How to change CSS property before element is created?

How to change CSS property before element is created?

Anonymous User 2573 28-Dec-2012
Hello every one

I have to modify the div's css before the window.onload, and body.onload. 

<html>
    <head>
        <style type="text/css">
            html, body {
                width: 100%;
                height: 100%;
                padding: 0px;
                margin: 0px;
            }
            div {
                margin-left: auto;
                margin-right: auto;
            }
        <script>
 
HTMLDivElement.prototype.style.marginTop = (window.innerHeight/2 - HTMLDivElement.scaleHeight/2) + "px";
        </script>
    </head>
 
    <body>
        <div>
        foo<br/>bar
        </div>
    </body>
</html>

Thanks in advance


Updated on 28-Dec-2012
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By