Support » Fixing WordPress » How To Center Youtube Video!?

Viewing 10 replies - 1 through 10 (of 10 total)
  • did you add a class like:

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

    The code didn’t work.

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

    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>

    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    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. 😉

    I tried both of your suggestions and neither worked.

    It seems odd that this is so difficult.

    Moderator Jan Dembowski

    (@jdembowski)

    Brute Squad and Volunteer Moderator

    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

    (@wpyogi)

    Forum Moderator

    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.

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

    I will look into the custom CSS plugin.

    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.

    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.