6

I'm using the featherlight lightbox to open iframes with different widths, please see the 1st 2 links on the fiddle below:

http://jsfiddle.net/sm123456/d5Lvw1rs/

The issue is that I seem I cant seem to be able to make the iframe responsive ie. when the browser window goes below the iframe width, the iframe should switch to 100%.

I've tried the code below which should work great, but doesn't, even when removing data-featherlight-iframe-height="575" data-featherlight-iframe-width="800".

data-featherlight-iframe-style="width: 100% !important; max-width: 800px !important;"

Any assistance would be very much appreciated!

JimWids
  • 113
  • 9
  • 1
    Did you fix your problem? Because for me, your JSFiddle is doing exactly what you want. As soon as the window is smaller than 920px, it's going to 100% the window width. – Alex Berger Oct 27 '22 at 07:05
  • No havent fixed it yet! But there are 2 different sized (width) iframes.. 1 is 800px and 1 is 1350px. – JimWids Oct 28 '22 at 11:12

3 Answers3

4

After reading the documentation, I found out you can add a custom class to the lightbox using the data-featherlight-variant="classname" attribute. Using this attribute, I added a different class to both the 800px and the 1350px one. Using that class, I applied the style. Check the JSFiddle to see it in action.

For the 800px width one:

data-featherlight-variant="custom-class-800"

@media only screen and (max-width: 800px) {
  .custom-class-800,
  .custom-class-800 .featherlight-content{
    width: 100%;
  }
  .custom-class-800 .featherlight-content .featherlight-inner {
    margin: 0 auto;
  }
}

For the 1350px width one:

data-featherlight-variant="custom-class-1350"

@media only screen and (max-width: 1350px) {
  .custom-class-1350,
  .custom-class-1350 .featherlight-content {
    width: 100%;
    margin: 0;
  }
}

JS Fiddle

FUZIION
  • 1,606
  • 1
  • 6
  • 19
0

Hey @JimWids

Try to use that CSS:-

.featherlight-iframe .featherlight-content{
        /* dimensions: 1140px prevents iframe from spanning the full width of the browser */
        width: 80%;
        max-width: 1140px;

        /* spacing */
        margin: 0;
        padding: 0;
    }

    .featherlight-iframe .featherlight-inner{
        /* positioning */
        display: block;
        float: left;
        position: relative;

        /* dimensions */
    
        width: 100%;
    }
    .featherlight .featherlight-inner:after{
        /* dimensions */
        content: "";
        float: left;
        width: 80%;
    height:80%;
        padding-top: 57%;
        display: block;
        position: relative;
    }
}

Here is that code:- JS_Fiddle

DSDmark
  • 1,045
  • 5
  • 11
  • 25
  • Thanks but the smaller iframe (900px) will now stretch larger than 900px, surely the same with the larger one too but im on a small screen so its not evident to me – JimWids Nov 02 '22 at 03:43
0

use this css

@media (max-width: 1024px){
  .featherlight .featherlight-content {
      width: 100%;
  }
  .featherlight .featherlight-image {
      width: 100% !important;
      object-fit: cover;
  }
}
Junaid Shaikh
  • 1,045
  • 4
  • 19