Ror*_*ory 2 css tabs svg shapes clip-path
我尝试构建一个具有文本内容和边框(白色 1px 线)的梯形。
我发现了这样的例子:
height: 0;
width: 120px;
border-bottom: 120px solid #ec3504;
border-left: 60px solid transparent;
border-right: 60px solid transparent;
Run Code Online (Sandbox Code Playgroud)
这是一个 png 示例,如果我使用它作为透明颜色的背景,它会起作用,但有点像黑客,不太好......
“clip-path”似乎支持不够,那么还有其他方法吗?SVG 有可能吗?
提前致谢
您可以使用pseudo-element
并使用perspective
父级来创建该形状作为背景。
body {
background: lightblue;
}
div {
width: 150px;
height: 40px;
padding: 20px;
display: flex;
align-items: center;
justify-content: center;
position: relative;
-webkit-perspective: 130px;
perspective: 130px;
margin: 50px;
}
div:after {
position: absolute;
width: 100%;
height: 100%;
background: lightgreen;
border: 1px solid white;
content: '';
left: 0;
top: 0;
z-index: -1;
-webkit-transform: rotateX(20deg) rotateY(0deg);
transform: rotateX(20deg) rotateY(0deg);
}
Run Code Online (Sandbox Code Playgroud)
<div>Some text</div>
Run Code Online (Sandbox Code Playgroud)