Get a CSS value with JavaScript

You can use getComputedStyle().

    var element = document.getElementById('image_1'),
        style = window.getComputedStyle(element),
        top = style.getPropertyValue('top');
    console.log(top);
<img id="image_1">

jsFiddle.

Leave a Comment