Ensuring the size of the description box remains constant during window resizing in a fancy and

When resizing the window, I noticed that the description box next to the pop-up image in fancybox does not adjust its size accordingly. The image reduces in size but the description box remains the same. Is there a way to make the description box resize along with the image? Any suggestions would be appreciated.

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

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:auto;
    left:-260px;
     margin-bottom:auto;
    /* CHANGES */
    top: 0;
}

.fancybox-title .child {
    height: auto;
    white-space:normal;
    text-align:left;
    height:470px;
    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');
   }

            });

Answer №1

Trying to understand your needs and the issue at hand is my priority. In my opinion, this solution works best. Allow me to elaborate: 1. If you adjust the window size, the text may not fit properly within the black div. 2. When viewed in a larger window, there may be empty space at the bottom.

Here are the modifications I made to your code:

.fancybox-title .child 
{
    height: auto;
    white-space:normal;
    text-align:left;
    /* height:470px; - Removed fixed height :) */
    padding:0 20px;
    max-width:200px;
    margin-right:auto;
    border-radius:0;
}

Let me know if this resolves the issue :)

UPDATE

I have made some tweaks to your code, which can be viewed here. Implementing dynamic height adjustment without jQuery proved challenging, so I included a simple function:

$( window ).resize(function() {
   imageHeight = $('.fancybox-inner').height();
    $('.fancybox-title').height(imageHeight);
});

By obtaining the image height and adjusting the text container accordingly. To make it function correctly, you will also need to modify certain aspects of the CSS:

.fancybox-title {
    right:auto;
    height:auto; /* This container now adjusts its height based on the image */
    left:-260px;
    margin-bottom:auto;
    top: 0;
}

.fancybox-title .child {
    white-space:normal;
    text-align:left;
    padding:0 20px;
    max-width:200px;
    margin-right:auto;
    border-radius:0;
    height:100%; /* Maintains consistent sizing with other elements */
}

Awaiting your feedback :)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Javascript behavior during execution can vary from what is observed during debugging

I'm currently facing an issue while trying to debug a script. Everything seems to work fine in debug mode, but not during runtime. Here's the JavaScript function causing trouble: function Add() { ... $('#Value').val($('#V ...

Angular 10 is displaying a message indicating that a font has not been

I'm facing an error in my Angular project when trying to add a font to the SCSS file. How can I resolve this issue? style.scss: @import "~@angular/material/theming"; @include mat-core(); $PWP-primary: mat-palette($mat-indigo); $PWP-accent: ...

Why does the event fail to trigger in an Angular 5 Kendo grid when the last character is deleted from the input box?

I have implemented a multi-filter in my Kendo Grid for an Angular 5 application. However, I am facing an issue where the event is not firing when the last character is deleted from the input box. How can I resolve this issue? For example, if I type ' ...

Troubleshooting issue with Bootstrap slider: CSS display problem

After downloading the Bootstrap slider from this link: https://github.com/seiyria/bootstrap-slider, I navigated to \bootstrap-slider-master\dist and transferred the bootstrap-slider.js and bootstrap-slider.min.js files to my js folder. Additional ...

vue utilize filtering to search through a nested array of objects within a parent array of objects

After making an API call, I receive JSON-formatted data with a specific structure like this: data = [ { name: 'John', school:[ { school_name: 'Harvard', date_attended: '2017-05-23' }, { schoo ...

What is the best way to enhance accuracy when hovering?

Have you ever noticed that the bottom menu becomes less precise when hovering over it on certain browsers? While Firefox seems to handle it perfectly, other browsers lack that smooth "snap" effect as you move through the numbers. I'm trying to find a ...

Executing cross browser testing in Node JS consecutively within a single session: A step-by-step guide

When conducting cross-browser testing, I prefer to run the tests individually rather than all together in one session. This way, I can ensure that all test results are accurately logged and generated into a single HTML report at the end of each session. I ...

Interact with a webpage element that is nested within another element using JavaScript

<div _ngcontent-tbs-c102="" class="tbis-div"><div _ngcontent-tbs-c102="" tabindex="0" class="hidden-xs" aria-label="2. Result for and displayed for your query"><span _ngcontent ...

Refresh Chart Information using Ng2-Charts in Charts.js

Utilizing chart.js and ng2-charts, I am developing gauge charts for my platform to monitor the fluid levels inside a machine's tank. The values are retrieved from an external API, but I am encountering an issue where the charts are rendered before I ...

"Double the fun with fullcalendar.io - where every event is doubled

I am currently using a combination of rails and react.js for my latest project. Let's say I create event A, but then have a change of heart and decide to cancel it via a bootstrap modal. Afterward, I start another event B and proceed to confirm it, ho ...

Using jQuery, retrieve the "select" element within a specific row of a

I am working on a table row that has the following HTML structure: When the user interacts with the "Name" field, I trigger the "select" event and pass it to the nameDropChanged function. Once I have a reference to this select element, I need to change th ...

Run the jQuery script once it has been successfully loaded using jQuery's .load method

On the Index.html page, there is a select box labeled #choose_content_to_load and a div named #get_loaded_content <select id="choose_content_to_load"> <option>Some content from the page content.html and div #content</option> </select ...

jQuery element with listener not triggering as expected

I'm facing some confusion while working on this issue. I am attempting to create a dynamic form where users can add descriptions, checkboxes, and number inputs as they please. Currently, I have developed a simple dynamic form using jQuery, which allow ...

Internet Explorer 10 considers content="IE=9" as the default standard for pages, yet it does not automatically apply them

I have a website built on ASP.NET 2.0. I am trying to make IE10 render all pages in compatibility mode IE9. I have added the following meta tag: <meta http-equiv="X-UA-Compatible" content="IE=9" /> However, when I open a page and check Developer T ...

AngularJS is encountering an issue with the callback function, resulting in an error

Currently, I am utilizing the $timeout service in Angular to decrease a variable from 100 to 1 in increments of 1/10 seconds. Although I understand that using the $interval service would be a simpler solution, for this particular scenario, I am focused on ...

Axio GET request in VueJS does not return a response body when using Amazon API Gateway

UPDATE: While Postman and browsers are able to receive valid response bodies from an Amazon API Gateway endpoint, other web applications are not. This is a basic GET request with no headers, and no authentication is needed for the API endpoint. The data is ...

Using PHP, let's display the next image

My website showcases image galleries organized in table format, like this: <table id="gallery"> <tr> <td><a href="largeimg.php?imageID=images/seascape/medium.Vietnam 19.jpg&caption= Vietnam, Cat Ba Island, Vietnam - 2015">< ...

A guide on choosing a custom button color and automatically reverting to its original color when another button is clicked

I have a collection of 24 buttons, all in a dark grey (#333333) shade. Whenever I click on one of the buttons, it changes to a vibrant blue color (#0099ff), which is functioning correctly. However, when I proceed to click on another button, the previous ...

Utilizing JavaScript or PHP to assign a uniform class to dynamically generated elements

Hello! In my online shop, each category has a page with all subcategories and a table of products. I want each product row in the table to have the same color as its corresponding sorting button for the subcategory. This must be done dynamically as I hav ...

Search for a DIV element within iMacro on a consistent basis

I recently started using iMacro and encountered an issue while recording a script that involved clicking on a pop-up when it appeared on the screen. The problem arose because the pop-up only appears when a new event is posted. Therefore, when I initially c ...