Adding border-radius for embedded YouTube video

后端 未结 11 959
梦谈多话
梦谈多话 2020-12-17 09:09

Please see this fiddle. Notice instantly before loading the border-radius works fine. A few milliseconds later the rounded corners disappear.

How can I

11条回答
  •  再見小時候
    2020-12-17 09:34

    Here's an easy yet very practical and useful "hack-solution" to this challenging problem.

    Just embed your iframe in a "div" element like this:

      

    then add the following css to your HTML:

     div {
       position: relative;
       display:inline-block;
       margin:200px;
    }
    div:before {
        content: '';
        position: absolute;
        z-index: 5000;
        display: block;
        top: -27px;
        left: -27px;
        right: -27px;
        bottom: -27px;
        background-color: transparent;
        pointer-events: none;
        border: 30px solid white;
        border-radius: 50px;
    }][1]
    

    This is quite a flexible solution, though it uses some additional layer for border-radius. This method is also compatible with most (all) modern browsers. Hope it was useful.

提交回复
热议问题