Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I created a dialog-box on my landing page that pop-ups when the page loads only once, but i am not able to make it responsive. I tried setting min-width and max-width but that won't help. What should i try?

What I have tried:

CSS
#mask {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 9000;
  background-color: #000;
  display: none;
}

#boxes .window {
  position: absolute;
  left: 0;
  top: 0;
  width: 440px;
  height: 200px;
  display: none;
  z-index: 9999;
  padding: 20px;
  border-radius: 15px;
  text-align: center;
}

#boxes #dialog {
  width: 750px;
  height: 300px;
  padding: 10px;
  background-color: #ffffff;
  font-family: 'Segoe UI Light', sans-serif;
  font-size: 15pt;
}

#popupfoot {
  font-size: 16pt;
  position: absolute;
  bottom: 0px;
  width: 250px;
  left: 250px;
}


// This is Jquery.
JavaScript
$(document).ready(function() {	

 //if the cookie hasLaunch is not set, then show the modal window
    if (!readCookie('hasLaunch')) {
        //launch it
        launchWindow('#dialog');        
        //then set the cookie, so next time the modal won't be displaying again.
        createCookie('hasLaunch', 1, 1);
    }

	
	
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();

$('#mask').hide();
$('.window').hide();
});

});

function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function launchWindow(id) {

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({'width':maskWidth,'height':maskHeight});

        //transition effect     
        $('#mask').fadeIn(500);    
        $('#mask').fadeTo("slow",0.9);  

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top',  winH/2-$(id).height()/2);
        $(id).css('left', winW/2-$(id).width()/2);

        //transition effect
        $(id).fadeIn(2000); 


}


// this is html code
HTML
  <div id="boxes">
  <div id="dialog" class="window">
    Welcome to GospelBox!!!
    <div id="popupfoot"> <a href="/content/about.html">  Okay </a> | <a  class="close" style="color:red;" href="#" >Skip this step </a> </div>
  </div>
  <div id="mask"></div>
</div>
Posted

1 solution

Why not you are using bootstrap built-in responsive dialog box, like #modal ? and many others. Low cost and high efficiency, I would recommend you to work on.
 
Share this answer
 
Comments
Member 13339398 2-Aug-17 0:24am    
I tried bootstrap modal but it is not working, i even included bootstrap scripts and css. What should i do?
[no name] 2-Aug-17 1:23am    
You have to also include JQuery and Bootstrap.js files for Modal, see the following link and compare your code with the code in this link.
[no name] 2-Aug-17 1:24am    
https://www.w3schools.com/bootstrap/bootstrap_modal.asp
Hope so it will work....
Don't forget to mark my good rating. :)
Member 13339398 2-Aug-17 2:13am    
Thanks for the help, i was actually using previous version of bootstrap

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900