Home > DeveloperSection > Forums > How to change CSS property before element is created?
john rob

Total Post:108

Points:756
Posted on    December-28-2012 8:02 AM

 CSS-CSS3 CSS-CSS3 
Ratings:


 1 Reply(s)
 1316  View(s)
Rate this:
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



AVADHESH PATEL

Total Post:604

Points:4228
Posted on    December-28-2012 8:05 AM

Hi John rob

Without changing your HTML code try this code:

 <style type="text/css">       

        #nav

        {

            width: 100%;

            overflow: auto;

            border: solid 1px red;

        }

        #ulListNavi

        {

            margin: 0;

            padding: 0;

            list-style: none;

        }

        #nav #ulListNavi li

        {

            float: left;

        }

        #nav #ulListNavi li a

        {

            margin-left: 5px;

        }

    </style>



Modified On Dec-28-2012 09:40:43 AM

Don't want to miss updates? Please click the below button!

Follow MindStick