Creative Menu Toggle Effects on Click with Images

Creative Menu Toggle Effects on Click with Images

Html


<div class="toggle"></div>

CSS


body
{
    margin: 0;
    padding: 0;
    background: #262626;
}
.toggle
{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    width: 240px;
    height: 102px;
    background: url(menu.png);
    cursor: pointer;
}
.toggle:before
{
    content: url(close.png);
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 100%;
    overflow: hidden;
    transition: width .5s;
}
.toggle.active:before
{
    width: 100%;
    transition: width .5s;
}

Javascript


<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $('.toggle').click(function(){
            $('.toggle').toggleClass('active');
        })
    })
</script>

See Demo

Leave a Comment