While javascript pop-ups are sufficient for most situations in which we have to pass a little information to the client, they are very inflexible.
They are inflexible in terms of customization. We can't add colors, images, buttons or any other kind of design modifications. In such situations, HTML elements designed to look like pop-ups do the job. People normally call them light-box type pop-ups, probably because they normally come with a translucent background.
Here is how to make one for you website. Unlike my previous tutorials, this tutorial does not feature a working example right here. Instead you can view the working example on this link:
What it does:
- There is a button on this page
- Use click the button and the popup appears
- There is an image in this pop-up. Alternatively, there can be text or any other kind of HTML content placed here too.
The first step into making this is the HTML part, which is as following:
- <div id="shekhoolbcontainer" align="center" onclick="this.style.visibility='hidden'">
- <div id="shekhoolb">
- <img src="mindzip-invite-small.jpg" />
- </div>
- </div>
The above code defines the lightbox. It does not contain the button which makes it appear. The code of the button is as follows:
- <button onclick="document.getElementById('shekhoolbcontainer').style.visibility='visible'">SHOW LIGHTBOX</button>
The important part of this button code is the onclick attribute, which selects the lightbox container element by id and toggles its visibility.
The CSS is as follows:
If you have any doubts about the whole structure of the program, you can look at the file. I have pasted the link above.
- #shekhoolbcontainer
- {
- width:100%;
- height:100%;
- position:absolute;
- top:0px;
- left:0px;
- visibility:hidden;
- z-index:+999;
- background-image:url(lb-bg-image.png);
- display:block;
- }
- #shekhoolb
- {
- background-color:#FFF;
- width:100%;
- height:95%;
- padding-top:2%;
- }
No comments:
Post a Comment