JSFiddle - React, Tailwind, and code Playground

by adeneo

HTML

<div id="annonse"></div>

CSS

body {height: 2000px;}

#annonse {
    position:absolute; 
    height: 600px; 
    width: 160px; 
    top: 100px;
    left: 500px;
    background: url(http://www.google.com/help/hc/images/adsense/adsense_185665_adformat-text_160x600_en.png);
}

JavaScript

$(function() {
    var ad = $("#annonse"),
        adTop = $("#annonse").offset().top;
    
    $(window).on('scroll', function() {
        var T = $(this).scrollTop();
        if (T>adTop) {
            ad.css({position : 'fixed', top: 0});
        }else{
            ad.css({position : 'absolute', top: adTop});
        }
    });
});