Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

centering a youtube video in css i wanna make a video page and center the video in middle i tried but i doesnt move

i wanna make a video page and center the video in middle i tried but i doesnt move

5 Answers

vtest

{ margin: 0px auto; } and i tried left:50% top:50% transform:translate i applied alot of videos

evan rost
evan rost
Courses Plus Student 13,971 Points

what element are you targeting? is this for a code challenge?

no i,m making a website and i completed it but i wanna make a video page and im targeting the i frime and i give it an id then i put it in a div and no thing happent

evan rost
evan rost
Courses Plus Student 13,971 Points

its hard to tell without seeing more of your code. is your project on github? here is a link to a good article on css centering. https://css-tricks.com/centering-css-complete-guide/

Create a div class in your HTML file and use align-content: center; property in CSS to center it

idid but it appears left top it doesnt move

thanks alot bro i.ll see

Is it a YouTube iframe embed code? If so, wrap the entire <iframe>....</iframe> in another set of <div> </div> tags and set <div style="text-align:center">. Maybe not the most elegant solution, but it works for the YouTube embeds. So, for example (I just picked a random video):

<div style="text-align: center;">
    <iframe width="560" height="315" src="https://www.youtube.com/embed/zrdQrHu158E" frameborder="0" allowfullscreen></iframe>
</div>
evan rost
evan rost
Courses Plus Student 13,971 Points

you may have to make the parent elements width 100%, then try centering the child element