Force iframe YouTube video to center fit and full cover the screen in the background using HTML5 CSS3

Full-size YouTube video, all aspect ratios, CSS only TL:DR – working fiddle As an update/improvement to @Hinrich’s answer, I have created a CSS-only scaler that works for ALL aspect ratios – even the extremes. Rather than over-compensating the width to fit most screen sizes, the iframe is set using vw and vh and offset using … Read more

Failed to execute ‘postMessage’ on ‘DOMWindow’: https://www.youtube.com !== http://localhost:9000

I believe this is an issue with the target origin being https. I suspect it is because your iFrame url is using http instead of https. Try changing the url of the file you are trying to embed to be https. For instance: ‘//www.youtube.com/embed/’ + id + ‘?showinfo=0&enablejsapi=1&origin=http://localhost:9000’; to be: ‘https://www.youtube.com/embed/’ + id + ‘?showinfo=0&enablejsapi=1&origin=http://localhost:9000’;