html - 使用 HTML、CSS 绘制三角形和形状
问题描述
我正在创建一个 HTML 页面,该页面将在形状下写入文本,请参阅图片以供参考。为了绘制这个形状,我使用以下:
#chevron {
position: relative;
text-align: center;
padding: 12px;
margin-bottom: 6px;
height: 60px;
width: 100%;
}
#chevron:before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 51%;
background: red;
transform: skew(0deg, 6deg);
}
#chevron:after {
content: '';
position: absolute;
top: 0;
right: 0;
height: 100%;
width: 50%;
background: red;
transform: skew(0deg, -6deg);
}
<div style="width: 100%">
<div id="chevron">
</div>
</div>
解决方案
你可以使用clip-path
这个网站很好地掌握它
在你的情况下,你需要这样的东西:
clip-path: polygon(100% 0, 100% 15%, 50% 25%, 0 15%, 0 0);
推荐阅读
- node.js - "gulp serve" 将返回此错误 "ReferenceError: primordials is not defined"
- java - 如何判断列表是否已经加载?
- arrays - 为什么在一个单元中只考虑数组的第一个元素?
- swift - Xcode:在框架模块中包含非模块化标头
- orm - 有没有人将对象图存储为单个文件而不是使用 ORM?
- tensorflow - 在不同机器上保存和加载 Universal Sentence Encoder 模型
- node.js - 如何从 mongdb find() 中检索键值
- sorting - 删除重复项,计数器增加
- sql - 当同一列中的值不匹配但不同列重复时将返回结果的 SQL 查询
- pine-script - Pine Script:我想编写一个条件,其中任何 3 个连续的红色蜡烛收盘低于 ma