Create A 3D Perspective Modal Window with jQuery and CSS3

File Size: 2.84 KB
Views Total: 2636
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
Create A 3D Perspective Modal Window with jQuery and CSS3

A small jQuery script which allows you to open a 3D perspective modal window from the right side of your browser window. Built with CSS3 transform, transition and perspective properties.

How to use it:

1. Include Ionicons icon font in the head section of your web page (Optional. Required for modal close icon).

<link rel="stylesheet" href="//">

2. Create the Html for a modal window as follow.

<div class="modal"> <a href="#" class="close"><i class="ion-close"></i></a>
  <figure> <img src="1.jpg" alt="" />
      <h1>Perspective Modal</h1>
      <p>Text Content</p>

3. Create an element to toggle the modal window.

<a href="#" class="open ">Close Modal</a>

4. The required CSS/CSS3 styles for the 3D perspective modal window.

.modal {
  -webkit-transition: all 300ms ease;
  transition: all 300ms ease;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  position: fixed;
  top: 10%;
  right: 3rem;
  width: 18rem;
  height: 35rem;
  background-color: #2c3e50;
  color: white;
  -webkit-transform: perspective(300px) rotateY(-5deg);
  transform: perspective(300px) rotateY(-5deg);
  -webkit-transform-origin: middle right;
  -ms-transform-origin: middle right;
  transform-origin: middle right;
  -webkit-font-smoothing: antialiased;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;

.modal:after {
  content: '';
  width: 100%;
  height: 1rem;
  position: absolute;
  left: 0;
  bottom: -3rem;
  background-image: -webkit-radial-gradient(ellipse, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0) 60%);
  background-image: radial-gradient(ellipse, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0) 60%);

.modal .close {
  position: absolute;
  top: 0;
  right: 0;
  width: 3rem;
  height: 3rem;
  line-height: 3rem;
  font-size: 2rem;
  background-color: rgba(0, 0, 0, 0.5);
  text-align: center;

.modal figcaption { padding: 2rem; }

.modal figcaption p { line-height: 1.2rem; }

.closed {
  -webkit-transition: all 300ms ease;
  transition: all 300ms ease;
  right: -25rem;

5. Include the necessary jQuery library at the bottom of the web page.

<script src="//"></script> 

6. The Javascript to open the modal window on page loaded.

var openCloseBtn = $('.open');
var openCloseText = $('span', '.open');
var modalWindow = $('.modal');
var modalCloseBtn = $('.close');{

function openCloseModal(isOpen){
    openCloseText.html('Open Modal');
  } else{
    openCloseText.html('Close Modal');

This awesome jQuery plugin is developed by SebL. For more Advanced Usages, please check the demo page or visit the official website.