WordPress.org

Support

Support » How-To and Troubleshooting » How To Center Youtube Video!?

How To Center Youtube Video!?

Viewing 10 replies - 1 through 10 (of 10 total)
  • xmatter
    Member

    @xmatter

    did you add a class like:

    <div style="margin:0 auto; width: VIDEO WIDTH">VIDEO LINK</div>
    trav4312
    Member

    @trav4312

    The code didn’t work.

    Could you make a code for this link: http://www.youtube.com/watch?v=_2YKJZlob3o

    xmatter
    Member

    @xmatter

    here is an iframe, try it

    <iframe width="560" height="315" src="//www.youtube.com/embed/_2YKJZlob3o" frameborder="0" style="margin:0 auto" allowfullscreen></iframe>

    Jan Dembowski
    Volunteer Mod. & Brute Squad

    @jdembowski

    Don’t add classes that will get munged by the post editor.

    Try this code instead and use the center option in the editor.

    [embed] http://www.youtube.com/watch?v=oHg5SJYRHA0[/embed]

    Wrapping the link in [embed][/embed] will let the oEmbed handle it but you can use the Visual Editor to center that line.

    Edit: That goes triple for using iframes. Don’t do that. 😉

    trav4312
    Member

    @trav4312

    I tried both of your suggestions and neither worked.

    It seems odd that this is so difficult.

    Jan Dembowski
    Volunteer Mod. & Brute Squad

    @jdembowski

    Link to post with that YouTube video?

    Edit: Whoops, you did. http://informationwarfareblog.com/

    Create a new post and put just that YouTube URL in it. Then share with us that link to that new post.

    WPyogi
    Forum Moderator

    @wpyogi

    Try adding this to your CSS:

    .post_content iframe {
       margin: 0 auto;
    }

    You should add to a custom CSS option or plugin – so that it does not get overwritten when the theme is updated.

    trav4312
    Member

    @trav4312

    Thanks WPyogi! It worked, you truly are a yogi.

    I will look into the custom CSS plugin.

    bernardfrancois
    Member

    @bernardfrancois

    WPyogi: this worked for me, but only with the following modification:

    .post_content iframe {
       display: block;
       margin: 0 auto;
    }

    I assume that whether this is required depends on display:block; already being present or not elsewhere in the theme’s CSS.

    Ricardo Durand
    Member

    @ricardo-durand

    Just put the code between <center></center>, and it’s done.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘How To Center Youtube Video!?’ is closed to new replies.