Is there a way to create a triangle display of a HTML video tag using CSS border-radius?

huangapple go评论56阅读模式
英文:

Is there a way to create a triangle display of a HTML video tag using CSS border-radius?

问题

我正在尝试在三角形显示中展示HTML视频标签,而不是默认的矩形显示。这意味着默认显示如下:

<!DOCTYPE html>
<html>

<head>
  <title>Video Default</title>
</head>

<body>

  <video width="640" height="360" controls>
    <source src="https://durendel.com/event/theater/gravityphase.mp4" type="video/mp4">
    Your browser does not support the video tag.
  </video>

</body>

</html>

请注意,默认显示是矩形形状,我想要将显示变为三角形形状,就像下面这样:

Is there a way to create a triangle display of a HTML video tag using CSS border-radius?

我尝试使用CSS来完成这个任务,具体来说是border-top-left-radiusborder-top-right-radius,但我只能使其呈现为曲线形状。以下是代码:

video {
  border-top-left-radius: 200px;
  border-top-right-radius: 200px;
  overflow: hidden;
}
<!DOCTYPE html>
<html>

<head>
  <title>Video</title>
</head>

<body>

  <video width="640" height="360" controls>
    <source src="https://durendel.com/event/theater/gravityphase.mp4" type="video/mp4">
    Your browser does not support the video tag.
  </video>

</body>

</html>

正如您从上面的代码片段中看到的,左右角只是呈现为曲线而不是形成尖角。因此,是否可以使用CSS border-radius 创建HTML视频标签的三角形显示?或者是否可以提供一些建议,告诉我如何完成这个任务?

英文:

I am attempting to show a HTML video tag in a triangle display. So, as opposed to the default rectangle display; a triangle. Meaning, here's the default display:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
  &lt;title&gt;Video Default&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

  &lt;video width=&quot;640&quot; height=&quot;360&quot; controls&gt;
  &lt;source src=&quot;https://durendel.com/event/theater/gravityphase.mp4&quot; type=&quot;video/mp4&quot;&gt;
  Your browser does not support the video tag.
&lt;/video&gt;

&lt;/body&gt;

&lt;/html&gt;

<!-- end snippet -->

Notice how the default display is the rectangle form - my aim is to get the display in a triangle form - like this:

Is there a way to create a triangle display of a HTML video tag using CSS border-radius?

I am trying to use CSS to accomplish this task, specifically border-top-left radius and border-top-right-radius, but I can only get it to curve. Here's the code below:

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-css -->

video {
  border-top-left-radius: 200px;
  border-top-right-radius: 200px;
  overflow: hidden;
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
  &lt;title&gt;Video&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

  &lt;video width=&quot;640&quot; height=&quot;360&quot; controls&gt;
    &lt;source src=&quot;https://durendel.com/event/theater/gravityphase.mp4&quot; type=&quot;video/mp4&quot;&gt; Your browser does not support the video tag.
    &lt;/video&gt;

&lt;/body&gt;

&lt;/html&gt;

<!-- end snippet -->

The problem I'm running into, as you can see from the code snippet above, the left and right angles only curve as opposed to forming a point. Therefore, is it possible to create a triangle display of a HTML video tag using CSS border-radius? Or can someone provide some additional guidance as to what I should be using to accomplish this task?

答案1

得分: 2

I doubt this is possible with border-radius.

但你可以用 clip-path 来实现这个效果

video {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
<!DOCTYPE html>
<html>
  <head>
    <title>Video</title>
  </head>
  <body>
    <video width="640" height="360" controls>
      <source src="https://durendel.com/event/theater/gravityphase.mp4" type="video/mp4"> Your browser does not support the video tag.
    </video>
  </body>
</html>
英文:

I doubt this is possible with border-radius.

But you can achieve this with clip-path

<!-- begin snippet: js hide: false console: true babel: null -->

<!-- language: lang-css -->

video {
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

<!-- language: lang-html -->

&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
  &lt;title&gt;Video&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;

  &lt;video width=&quot;640&quot; height=&quot;360&quot; controls&gt;
    &lt;source src=&quot;https://durendel.com/event/theater/gravityphase.mp4&quot; type=&quot;video/mp4&quot;&gt; Your browser does not support the video tag.
    &lt;/video&gt;

&lt;/body&gt;

&lt;/html&gt;

<!-- end snippet -->

huangapple
  • 本文由 发表于 2023年2月7日 02:11:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/75365078.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定