Fixed navbar in right sidebar

CSS Code:
<style>
    body {
        font-family: arial
    }
    .anythingFixed {
        position: fixed;
        top: 25%;
        right: 0;
        background: #000;
        color: #fff;
        padding: 10px;
    }
    .btnri {
        position: fixed;
        transition: all 0.5s;
        top: 30%;
        background: #f00;
        right: 0;
        color: #fff;
        padding: 10px;
        margin-right: 0px;
        width: 100px;
    }
    .margg {
        margin-right: -120px;
    }

</style>

HTML Code:
<div class="anythingFixed">ClickMe </div>
<div class="btnri">Move</div>

Jquery Code:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
    $(document).ready(function () {
        $('.anythingFixed').click(function () {
            $('.btnri').toggleClass('margg');
            });
        });
</script>

No comments:

Note: Only a member of this blog may post a comment.

Copyright Reserved to Anything Learn. Powered by Blogger.