How to modify the height or width of an iframe?

224 Views Asked by At

I am faciing an issue with the iframe size. So currently, i have an iframe in which there is a chatbot button, I have integrated this chatbot using botpress with my own website. now the problem is due this iframe at the bottom right corner, if I increase the size of chatbot button, it getscropped off due to the limited size of iframe. so how to make its sie larger, I have its class name, and seeing in the browser console , I need some css code to modify the size. I tried but doesnot work with css

1

There are 1 best solutions below

2
Matt Franca On

You should be able to modify the iframe element with CSS styling specifically with the height and width properties:

<iframe style="width: 100%; height: 710px;" ...>
</iframe>

The second alternative, you could attempt to use the iframe attributes of width and height:

<iframe width="100%" height="100%" ...>
</iframe>

You mentioned it does not seem to work from CSS, this might be due to it inheriting size from a parent element, but that's speculation since you did not post a code reference. If that is the case, you could use the !important keyword to force the style sizing for the iframe:

<iframe style="width: 100% !important; height: 710px !important;" ...>
</iframe>

The above is inline styling, if you wanted to get this to work with an iframe CSS class selector:

.myIframeClass {
  height: 100%;
  width: 100%;
}

If you are in need of overriding inherited sizing then using the !important keyword can be used here as well within your CSS class selector styling:

.myIframeClass {
  height: 100% !important;
  width: 100% !important;
}

Take a look at this reference, it has some useful information on working with iframes.