views:

318

answers:

1

i have seen some answers to this but i think i am actually having a css issue.

here is a sample fragment of my html < id=container> children children if i pop open the modal there is a print button. when i click it i use jQuery to apply a .noprint to #container and .print to #modal. but the .print to modal is disregarded. no matter what selector i apply i cant get the modal content to appear. What's worse, i cant use firebug, it is not showing me what print styles are being applied. i have tried #container #modal.print {display: block; }etc...

thanks!

+2  A: 

From the sound of it, your modal element is inside of the container. I'm guessing you have markup like this.

<div id="container">
    <span>children</span>
    <p>more children>
    <div id="modal">
        Modal text!
    </div>
</div>

And CSS like this...

.noprint { display: none;}
.print {display: block;}

Which you use JavaScript to apply, like this:

<div id="container" class="noprint">
    <span>children</span>
    <p>more children>
    <div id="modal" class="print">
        Modal text!
    </div>
</div>

In these examples, the #modal element is inside of a hidden container. The CSS spec dictates that if a parent element is hidden, all children will be hidden also, even if they are set to display: block (or any other valid display value) or are absolutely positioned.

What you should do if you want to hide everything on the page except for your modal window is get your markup to be structured something like this:

<div id="modal">
    Modal Text!
</div>
<div id="container">
    <span>children</span>
    <p>more children>
    <div id="modal">
        Modal text!
    </div>
</div>

If you have no control over where the modal element is rendered, you can use jQuery to re-position the modal element. Keep in mind that this may impact your modal window's layout:

// Moves the element outside of the hidden container
$("#container").before($("#modal"));
Dan Herbert
this last thing, moving the box worked! very good "thinking outside the box" LOL thanks!