Responsive CSS to Crop YouTube Thumbnail Black Bars

If you’ve ever use YouTube thumbnail images you’ve likely been as frustrated as me that they tend to come with black bars at the top and bottom of it.  Given my video producer background and the history of YouTube I understand why they are there, but they are frustrating.  You can learn more about the image sizes and formats in this post: YouTube Image Thumbnail URLs.

HTML and CSS to create a responsive YouTube thumbnail image with playbutton and without black bars.
HTML and CSS to create a responsive YouTube thumbnail image with playbutton and without black bars.

So when you want to use these images in a webpage and crop off of the black bars at the top on bottom, and ensure that the image scales correctly in a responsive design website, it can be a bit tricky.  There’s a lot to consider here.  Not to mention that you’ll typically want to add a play button over the top of it as well and ensure that it’s always centered regardless of the window size.

While it’s possible to write CSS that works in a responsive layout, it’s not widely accessible through a Google search.  But I’ve come up with a solution, and thus wanted to share so it’s easy for me (or you) to find once again.

Live Example

I’ve put a working example here on a JSFiddle:

JSFiddle – Responsive YouTube Thumbnail Image 16:9

HTML

Responsive CSS

I hope this helps!