html - 在 CSS 中绘制三 Angular 形

标签 html css

<分区>

我明白了

border-top: 50px solid transparent;

表示上边框的厚度为 50px,纯色且没有颜色。

我也明白了

border-right: 100px solid red;

表示右边框为 100 像素厚,为实心且为红色。

但是我不明白怎么...

#triangle-left 
{ width: 0; 
 height: 0; 
 border-top: 50px solid transparent;
 border-right: 100px solid red; 
 border-bottom: 50px solid transparent;} 

可以做一个指向左边的三 Angular 形吗?

帮助理解将不胜感激。

最佳答案

CSS 边框实际上有对 Angular 线。

插图:

\-------/
|       |
|       |
|       |
/-------\

所以 border-right 实际上看起来像这样:

/
|
|
|
\

height:0pxborder-right 也没有高度,因此它看起来像这样:

/
\

现在,如果您使用以下 css:

#triangle-left{ 
    width: 0; 
    height: 0; 
    border-top: 50px solid transparent; /* this will fill the top gap */
    border-right: 100px solid red; /* this will be the red triangle */
    border-bottom: 50px solid transparent; /* this will fill the bottom gap */
}

你会得到:

CSS Triangle

一个指向左边的三 Angular 形。

关于html - 在 CSS 中绘制三 Angular 形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18293304/

上一篇:html - 这在 CSS 中正常吗?

下一篇:javascript - Jquery 在点击时添加/删除类

相关文章:

css - 嵌套的 CSS 计数器不显示增量

javascript - 使用jquery向表添加动态href

javascript - 使用jQuery淡入淡出div onclick

javascript - 单击空白区域时如何触发body.onclick

javascript - 为什么再次悬停时下拉菜单动画会削高?

css - 使用 CSS3 的梯形阴影

html - Bootstrap 表上的滚动条

css - hr 使父 div 在 IE7 中调整为 100%

javascript - 为什么谷歌地图不显示在我的网站上,我一直在使用开发者网站?

javascript - siblings CSS 规则与 React styled-components/CSS modules/CSS-in-JS