Set marginLeft CSS style property - Javascript CSS Style Property

Javascript examples for CSS Style Property:marginLeft

Description

Set marginLeft CSS style property

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#s4-ca {/*from  www .  ja v  a 2 s.  c  o m*/
   margin-left: 100px;
}


      </style> 
   </head> 
   <body> 
      <div id="s4-ca">
         Foo
      </div> 
      <script type="text/javascript">
document.getElementById('s4-ca').style.marginLeft = '0px';

      </script>  
   </body>
</html>

Related Tutorials