Creating a Fixed Overlay and Centered Popup with Div and CSS

css overlaycentered modaldiv css popupfixed positionhtml overlay
Published·Modified·

Preview

Preview Image

CSS Code

<style type="text/css">
body{
     font-family: "Microsoft YaHei" ! important;
}
/* Gray overlay layer */
.fade{
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    position: fixed;
    left: 0;
    top: 0;
    z-index: 99;
}
/* Popup layer */
.succ-pop{
    width: 400px;
    height: 300px;
    background: #fff;
    position: fixed;
    left: 50%;
    top: 50%;
    margin-left: -200px;
    margin-top: -150px;
    z-index: 999;
    border-radius: 5px;
}
   
.succ-pop h3.title{
    text-align: center;
    font-size: 22px;
    color: #ce002c;
}
</style>

HTML Code

<div class="fade"></div>
<div class="succ-pop">
    <h3 class="title">
        Content goes here
    </h3>
</div>