Search code examples
javascriptjqueryhtmlcssfancybox

Fancybox description box out of scope


I have this fancybox pop-up image with a description box. My problem is that when i re-size the browser from up to down (try it in the jsfiddle) the text seems to get out of the the box. Any idea on how to solve it?

JSFIDDLE: http://jsfiddle.net/tqnk7e3f/

Code: HTML:

<a caption="<h2>Image Header</h2><p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>" rel="Sold" class="fancybox" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/4_b.jpg"><img src="http://fancyapps.com/fancybox/demo/4_s.jpg" alt="" /></a>

        <a class="fancybox hidden" data-fancybox-group="thumb1" href="http://fancyapps.com/fancybox/demo/3_b.jpg"><img src="http://fancyapps.com/fancybox/demo/3_s.jpg" alt="" /></a>

        <a class="fancybox" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/2_b.jpg"><img src="http://fancyapps.com/fancybox/demo/2_s.jpg" alt="" /></a>

        <a class="fancybox hidden" data-fancybox-group="thumb2" href="http://fancyapps.com/fancybox/demo/1_b.jpg"><img src="http://fancyapps.com/fancybox/demo/1_s.jpg" alt="" /></a>

CSS:

.hidden {
    display: none;
}

.fancybox-title {
    right:auto;
    height:100%;
    left:-260px;
    margin-bottom:auto;
}

.fancybox-title .child {
    height:100%;
    white-space:normal;
    text-align:left;
    padding:0 20px;
    max-width:200px;
    margin-right:auto;
    border-radius:0;
}

.fancybox-title .child h2 {
    font-size:140%;
    line-height:1.5;
    margin-top:20px;
    margin-bottom:15px;
}

.fancybox-title .child p {
    margin-bottom:30px;
}

JQUERY:

     $('.fancybox').fancybox({
                prevEffect : 'fade',
                nextEffect : 'fade',
               padding:0,

                closeBtn  : true,
                arrows    : true,

               nextClick : true,    


               helpers : { 
    title : { type : 'outside' }
   },

               helpers : {

                    thumbs : {
                        width  : 80,
                        height : 80

                    }
                },



 beforeLoad: function() {
    this.title = $(this.element).attr('caption');
   }

            });

Solution

  • If i understand your problem well i suggest to change property of .fancybox-title from height:100% to height:auto. With response design it's always better for me to use auto height. check fiddle ! Let me know if it helps!

    EDIT

    So here's new fiddle.

    i updated few things :

     top: 0;
    

    against bottom:0

    and leave height:auto as it was in my previous example.

    .hidden {
        display: none;
    }
    
    .fancybox-title {
        right:auto;
        height:auto;
        left:-260px;
        margin-bottom:auto;
        /* CHANGES */
        top: 0;
    }
    
    .fancybox-title .child {
        height: auto;
        white-space:normal;
        text-align:left;
        padding:0 20px;
        max-width:200px;
        margin-right:auto;
        border-radius:0;
    }
    
    .fancybox-title .child h2 {
        font-size:140%;
        line-height:1.5;
        margin-top:20px;
        margin-bottom:15px;
    }
    
    .fancybox-title .child p {
        margin-bottom:30px;
    }
    

    Wainting again for your check :)