Changing top fill in javascript

Here, as I set the topmost registration in my css:

body {
    font-size: {{ font_size }}px;
    margin: 0;
    padding: 100px 0 20px 0;
    width:100% !important;
}

How to change the top pad, which is 100 pixels in the example above, using the simplest javascript function without using jQuery ?

+5
source share
2 answers
document.body.style.paddingTop = '10px'
+10
source

JavaScript syntax: object.style.paddingTop="2cm"

see link: http://www.w3schools.com/cssref/pr_padding-top.asp

so this should be:

<!-- note that this chunk of code should be after the body tag to work -->
<script type="text/javascript">
    document.body.style.paddingTop = "100px";
</script>
0
source

All Articles