Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Adding MediaElement.js

Botos Claudia
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Botos Claudia
Front End Web Development Techdegree Graduate 18,765 Points

My video is not centering after applying the div videoWrapper

My video is not centering and I have followed the exact steps as in the video and , also in Google Chrome. It doesn't seem to work either. Please Help!

4 Answers

Brodey Newman
Brodey Newman
10,962 Points

Hey Popa,

What is the CSS for the videoWrapper div?

A little trick I like to do is to wrap the video in a div like below:

<div class="video-wrap">
     <video width="320" height="240" controls>
          <source src="movie.mp4" type="video/mp4">
          <source src="movie.ogg" type="video/ogg">
               Your browser does not support the video tag.
     </video>
</div>

And add some css to the 'video-wrap' div.

.video-wrap {
     display: table;
     margin: auto;
}

You can also use flex box to center the video.

.videocontainer {
    display: flex;
    justify-content: center;
    width: 100%;
}

Hey! here is a more simpler version of centering your player. When you inspect your HTML, you will see a div with a class mejs__container applied to video and audio tags. Media element makes both video and audio div tags. You can use this mejs__container class to center your player.

.mejs__container {
   display: block;
   margin: 0 auto;
}

You should actually target .mejs_player and .mejs_player and use margin: 0 auto; to center the 2 elements.