Totara Learn Open Discussions

Centering an iframe

 
? ?
Centering an iframe
על ידי ? ? בתאריך 16/12/2019, 14:33
 

Hi

We are using an iframe in a lesson to link to our video stream from Vimeo.  How do I get it to display in the middle of the lesson page instead on the left?

This is the current embed code we are using

<iframe src="https://player.vimeo.com/video/tba" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen></iframe>


Thanks heaps

Craig Eves
Re: Centering an iframe
על ידי Craig Eves (Totara Support) בתאריך 16/12/2019, 18:30
קבוצה Totara

Hi Janine

I am not sure on how this can be achieved - if you add html code to center this the code is stripped out by the editor.

regards



Anna Ross
Re: Centering an iframe
על ידי Anna Ross בתאריך 17/12/2019, 11:00
 

Hi Janne,


We are using the Atto HTML editor and are on V10 with a responsive template. I can get an iframe to centre by adding a div around the iframe (bold) and putting style attributes on the div. The key part to getting this to work on our site is to set the width of the div to the same width as the iframe (underlined).

<div style="margin:0 auto; text-align: center; width:640px;">
<iframe src="https://player.vimeo.com/video/tba" allow="autoplay; fullscreen" allowfullscreen="" width="640" height="360" frameborder="0"></iframe>
</div>

Hope this is helpful.
? ?
Re: Centering an iframe
על ידי ? ? בתאריך 27/01/2020, 19:31
 
thanks Anna - it certainly was :)