レイヤーの固定

覚え書き

<style type="text/css">
#Layer1{
    height : 100px;
    width : 100px;
    position : absolute;
}
</style>

<script type="text/javascript">
    $(function(){
        $(window).scroll(function(){
           $("#Layer1").css("top",$(window).scrollTop());
           $("#Layer1").html($(window).scrollTop());
    
        })
    });
</script>

jQueryをインポートした上で


上記のコードでスクロールにあわせてレイヤーが付いてくる
レイヤーの中にはスクロール量を表示