WordPress.org

Forums

[closed] How To Center Youtube Video!? (11 posts)

  1. trav4312
    Member
    Posted 2 years ago #

    http://informationwarfareblog.com/

    I want to center these videos, nothing I have done will work!

  2. xmatter
    Member
    Posted 2 years ago #

    did you add a class like:

    <div style="margin:0 auto; width: VIDEO WIDTH">VIDEO LINK</div>
  3. trav4312
    Member
    Posted 2 years ago #

    The code didn't work.

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

  4. xmatter
    Member
    Posted 2 years ago #

    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>
  5. 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] [/embed]" rel="nofollow">http://www.youtube.com/watch?v=oHg5SJYRHA0[embed]

    Wrapping the link in [/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. ;)

  6. trav4312
    Member
    Posted 2 years ago #

    I tried both of your suggestions and neither worked.

    It seems odd that this is so difficult.

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

  8. WPyogi
    Forum Moderator
    Posted 2 years ago #

    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.

  9. trav4312
    Member
    Posted 2 years ago #

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

    I will look into the custom CSS plugin.

  10. bernardfrancois
    Member
    Posted 1 year ago #

    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.

  11. Ricardo Durand
    Member
    Posted 1 year ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic