Totara Learn Open Discussions

Centering an iframe

 
? ?
Centering an iframe
by ? ? - Monday, 16 December 2019, 2:33 PM
 

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
by Craig Eves (Totara Support) - Monday, 16 December 2019, 6:30 PM
Group 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
by Anna Ross - Tuesday, 17 December 2019, 11:00 AM
 

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
by ? ? - Monday, 27 January 2020, 7:31 PM
 
thanks Anna - it certainly was :)