9

Actually, two questions:

  • How can I create a modal popup with background color of gray?
  • Also I need to create for a cover background color only to table itself. Not to overall page.

How do I do this using javascript and css?

3
  • 1
    Had to unwind that question a little. Commented May 5, 2009 at 4:06
  • 2
    Duplicate of the question you asked on April 7th: stackoverflow.com/questions/724103/… Commented May 5, 2009 at 4:22
  • 3
    Guess it wasn't that urgent after all.. Commented May 7, 2009 at 18:34

2 Answers 2

10

Here is the HTML, which should probably be inserted with JS, and the styles should be in an external stylesheet.

<div style="background: gray; width: 200px; height: 200px; position: absolute; left: 50%; top: 50%; margin-left: -100px; margin-top: -100px" id="modal">I'm a modal</div>

Then, you could leverage jQuery to display it.

$('a.modal').bind('click', function(event) { 
    event.preventDefault();
    $('#modal').fadeIn(800);
});

This is only a start, you'll want to learn from this and build upon it. For example, the script should check is(':hidden') and show, and if not then fadeOut(800) or similiar.

Sign up to request clarification or add additional context in comments.

Comments

6

I use this for the mask that sits on top of the screen

.Mask {
   display: none;
   width: 100%;
   height: 100%;
   z-index: 9000;
   padding: 0px;
   margin: 0px;
   background: transparent url(http://i.imgur.com/0KbiL.png);
   position: fixed;
   top: 0px;
   overflow: hidden;
}

4 Comments

What does the mask.png file look like?
1x1px png which has .6 opacity.
@Ballsacian1 can you post a link to this png?
How are clicks outside the modal prevented from interacting with the elements outside it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.