Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a Border Radius to <video> tag in Chrome

I've seen this question pop up a couple of times without any clear resolution.

I'm loading a simple video

<video src="" controls></video>

Onto my page. The video works and plays well cross-browser (not showing all the format setup for this question since it isn't relevant).

I've then applied a border-radius to the video tag. This works, except in Chrome. I can even pull up the console and see the border-radius applied to the video tag, but it isn't rendering the border radius.

Is anyone familiar with this issue? I've read it's a bug in Chrome, but I'm not sure if it's been resolved or if there might be a workaround?

like image 685
Aaron Avatar asked May 07 '13 01:05

Aaron


1 Answers

I'm not sure but I think that this is what's meant by "using SVG":

The idea is to create a HTML overlay element that is the same width and height as the video, set multiple SVG backgrounds on it (border-radius's in whatever the background color is) and make it "mouse-invisible" (pointer-events: none):

Demo: http://jsfiddle.net/pe3QS/3/

CSS (minus the SVG's):

#video-container {
    position: relative;
}

#overlay {
    position: absolute;
    width: 320px;
    height: 240px;
    left: 0;
    top: 0;
    pointer-events: none;
    background-image: url('data:image/svg+xml...');
    background-position: top right, top left, bottom left, bottom right;
    background-repeat: no-repeat;
}

HTML:

<div id="video-container">
    <video width="320" height="240" src="http://www.w3schools.com/html/movie.ogg" type="video/ogg" controls></video>
    <div id="overlay"></div>
</div>

You could also use a psuedo-element (not on the video element, it would'nt display):

Demo: http://jsfiddle.net/pe3QS/2/

CSS:

#video-container:after {
    position: absolute;
    width: 320px;
    height: 240px;
    content: " ";
.....

HTML:

<div id="video-container">
    <video width="320" height="240" src="http://www.w3schools.com/html/movie.ogg" type="video/ogg" controls></video>
</div>

The SVG's are pretty simple to modify, just change the fill attribute on each of them.

This could probably also be done via JS.

like image 61
A.M.K Avatar answered Sep 25 '22 00:09

A.M.K