Also, the article mentioned above has also been released on CreativeBloq, on Responsive Youtube Embed. Update : This article has been updated to improve the quality since it was published. Check it out in issue # 247, available October 8th 2013. The article is more depth, suggesting some alternatives for embedding responsive videos in your web designs.
Net Magazine about the Responsive Youtube Embed and how to make YouTube Videos Responsive. Update: I was asked to write an article for. Check out our case study for O'neill surfing, which uses Vimeo videos to embed responsive videos that autoplay.Īvex is an NYC Digital agency, that focuses on creating amazing websites and engaging content. We have been exploring different ways to embed youtube videos for responsive design. Responsive YouTube Video Embed Exampleįor a working example, check out our homepage for embeded reponsive videos. Now, if the responsive YouTube embed worked, your videos should be responsive and ready to view on Tablets and Mobile devices.
Note: this responsive youtube embed code has been updated in 2020 to be more compliant and follow best practices for embedding Youtube videos for responsive design. Next, edit add some HTML around your embed code. Padding-top: 30px height: 0 overflow: hidden Awesome! Exactly what we need.įirst you will need to add the following to your style sheet. This will force the embed elements to expand fullwidth automatically. Then specify the child elements (iframe, object embed) 100% width, 100% height, with absolute position. You will need to wrap the responsive youtube embed code with a div and specify a 50% to 60% padding bottom. Here’s how to make a youtube video mobile: Surprisingly, Youtube does not automatically have a responsive embed code. One would think that videos that with 100% width would automatically resize to the surrounding container. Therefore, we needed a responsive YouTube video embed code. I wanted to know how to make a youtube video mobile. (uggh!) This looked fine on desktop computers, but pretty much broke the design when viewing on a mobile device. However, when I added the embed code, the video had a fixed height and width. Since this website is fully responsive, I needed the YouTube video to re-size depending on the browser size or device width. I came across a small problem when adding a video from YouTube to one of my blog posts about the Childish Gambino website that we created. However, this method requires the container to be relatively positioned and dedicated to the chart canvas only.Have you ever tried to make a YouTube video responsive? If so, it can be somewhat tricky. Chart.js uses its parent container to update the canvas render and display sizes. This can ease the resize process by debouncing update of the elements.ĭetecting when the canvas size changes can not be done directly from the canvas element. Gets passed two arguments: the chart instance and the new size.ĭelay the resize update by give amount of milliseconds.
Note that this option is ignored if the height is explicitly defined either as attribute or via the style.Ĭalled when a resize occurs. width / height, a value of 1 representing a square canvas). Maintain the original canvas aspect ratio (width / height) when resizing.Ĭanvas aspect ratio (i.e. Resizes the chart canvas when its container does ( important note.).
Chart.js needs a dedicated container for each canvas and this styling should be applied there.Ĭhart.js provides a few options to enable responsiveness and control the resize behavior of charts by detecting when the canvas display size changes and update the render size accordingly.