Page overlay jQuery/CSS

Idea

by Joshua Powell

HTML

<a href="#" class="add">Click to view page</a>

CSS

a {
    text-decoration: none;
}

body.active {
    background: rgba(0, 0, 0, 0.2);
}

.frameBody {
    position: relative;
    width: 400px;
    margin: 0 auto;
    top: 50px;
}

a.add {
    width: 150px;
    height: 40px;
    border-radius: 5px;
    display: block;
    background: brown;
    color: #f7f7f7;
    text-align: center;
    line-height: 40px;
}

a.close {
    position: absolute;
    left: 100%;
    bottom: 100%;
    width: 20px;
    height: 20px;
    display: block;
    background: brown;
    border-radius: 50%;
    border: 3px solid #E8E8E8;
    z-index: 100;
    text-align: center;
    color: #f7f7f7;
}

iframe {
    position: absolute;
    width: 400px;
    height: 400px;
}

JavaScript

$('.add').on('click', function() {
    var website = '<div class="frameBody"><a href="#" class="close">X</a><iframe src="http://www.w3schools.com"></iframe></div>';
    
    $('body').append(website).addClass('active');
    $('.close').on('click', function() {
        $('iframe, .close').remove();
        $('body').removeClass('active');
    });
});