开发者

Lightbox, floating a close button outside of an iFrame

Hey, I have decided to reword this question (as opposed to creating a new one)...

I have a Lightbox (Colorbox), which opens an iFrame with basic HTML content. In fact, here is a picture: alt text http://demo.squeezedigital.com/barrie-test/lightbox-help.gif

I would like the Close button to be where the Hollow White box is.

The Lightbox (Colorbox) CSS is as follows, nothing I seem to do works. :(

(The Colorbox JS file can be found here: http://colorpowered.com/colorbox/)

#colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden;}
#cboxOverlay{position:fixed; width:100%; height:100%;}
#cboxMiddleLeft, #cboxBottomLeft{clear:left;}
#cboxContent{position:relative; overflow:hidden; }
#cboxLoadedContent{overflow:hidden;}
#cboxLoadedContent iframe{display:block; width:100%; height:100%; border:0;}
#cboxTitle{margin:0;}
#cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%;}
#cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}

#cboxOverlay{background:#890000;}

#colorBox{}
    #cboxTopLeft{width:25px; height:25px; background:url(border1.png) 0 0 no-repeat;}
    #cboxTopCenter{height:25px; background:url(border1.png) 0 -50px repeat-x;}
    #cboxTopRight{width:25px; height:25px; background:url(border1.png) -25px 0 no-repeat;}
    #cboxBottomLeft{width:25px; height:25px; background:url(border1.png) 0 -25px no-repeat;}
    #cboxBottomCenter{height:25px; background:url(border1.png) 0 -75px repeat-x;}
    #cboxBottomRight{width:25px; height:25px; background:url(border1.png) -25px -25px no-repeat;}
    #cboxMiddleLeft{width:25px; background:url(border2.png) 0 0 repeat-y;}
    #cboxMiddleRight{width:25px; background:url(border2.png) -25px 0 repeat-y;}
    #cboxContent{background:#ab0a0e;}
        #cboxLoadedContent{margin-bottom:0px;}
        #cboxTitle{position:absolute; bottom:0px; left:0; text-align:center; width:100%; color:#999;}
        #cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;}
        #cboxSlideshow{position:absolute; bottom:0px; 开发者_如何学JAVAright:42px; color:#444;}
        #cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;}
        #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;}
        #cboxLoadingOverlay{background:url(loading.gif) 5px 5px no-repeat #fff;}
        /* THE CLOSE BUTTON */
        #cboxClose{position:absolute; top: 10px; right:10px; display:block; color:#000; z-index: 20; display: block; padding-top: 8px; padding-right: 8px; background-image: url(close-button.png); width: 83px; height: 25px;}

/* IE FIXES */
.cboxIE #cboxTopLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderTopLeft.png, sizingMethod='scale');}
.cboxIE #cboxTopCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderTopCenter.png, sizingMethod='scale');}
.cboxIE #cboxTopRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderTopRight.png, sizingMethod='scale');}
.cboxIE #cboxBottomLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderBottomLeft.png, sizingMethod='scale');}
.cboxIE #cboxBottomCenter{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderBottomCenter.png, sizingMethod='scale');}
.cboxIE #cboxBottomRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderBottomRight.png, sizingMethod='scale');}
.cboxIE #cboxMiddleLeft{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderMiddleLeft.png, sizingMethod='scale');}
.cboxIE #cboxMiddleRight{background:transparent; filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src=internet_explorer/borderMiddleRight.png, sizingMethod='scale');}


Insert to button in the HTML of the lightbox (check the script files, it must be there).


sigh, so I finally got it to work.

Turns out that in the jQuery.Colorbox.js file there is a section:

$content = $div("Content").append(
            $loaded = $div("LoadedContent").css({width: 0, height: 0}),
            $loadingOverlay = $div("LoadingOverlay"),
            $loadingGraphic = $div("LoadingGraphic"),
            $title = $div("Title"),
            $current = $div("Current"),
            $slideshow = $div("Slideshow"),
            $next = $div("Next"),
            $prev = $div("Previous"),
            $close = $div("Close") //This is the problem
        );

I simply changed the code to be:

$content = $div("Content").append(
                $loaded = $div("LoadedContent").css({width: 0, height: 0}),
                $loadingOverlay = $div("LoadingOverlay"),
                $loadingGraphic = $div("LoadingGraphic"),
                $title = $div("Title"),
                $current = $div("Current"),
                $slideshow = $div("Slideshow"),
                $next = $div("Next"),
                $prev = $div("Previous"),
                $close = $div("") //Removed the Close class on the Div
            );
    $content = $div("body").append( 
                $close = $div("Close") //Append Close button to Body, not Content
            );

Cheers anyway people.


The image from the question is not available anymore. I answer the question in general:

If you want the close button outside of the media area (image or video), just use jquery on the onLoad event and "move" the close button:

$('.videoitem', this).colorbox({ 
    onLoad: function() {
        $('#cboxOverlay').append($('#cboxClose'));
    },
    iframe:true, 
    innerWidth:640, 
    innerHeight:480,
});

I would style the close button to make it more visible, however it uses a background graphic. So my suggestion is to use a white box-shadow box-shadow: 1px 1px 12px #FFF;. Or just skip the background image and show the text label:

<style type="text/css">
    #cboxClose {
        text-indent:0; 
        color: #FFF; 
        right: 30px;
        background-image:none;
    }
</style>

No core hack needed as stated in the other answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜