Totara Learn Open Discussions

Centering an iframe

 
ButcherJanne
Centering an iframe
ButcherJanne 发表于 2019年12月16日 Monday 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
Eves (Totara Support)Craig 发表于 2019年12月16日 Monday 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



RossAnna
Re: Centering an iframe
RossAnna 发表于 2019年12月17日 Tuesday 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.
ButcherJanne
Re: Centering an iframe
ButcherJanne 发表于 2020年01月27日 Monday 19:31
 
thanks Anna - it certainly was :)