gpt4 book ai didi

html - 在顶部和底部创建一个倾斜按钮

转载 作者:行者123 更新时间:2023-11-28 15:31:53 24 4
gpt4 key购买 nike

我正在尝试创建一个带有两条斜线的按钮。我管理的从左下角到右中心的一个。下一个需要从左上到右。

左边的高度是50px,右边的高度应该是30px

.slantedButton {
position: relative;
box-sizing: border-box;
padding: 5px;
height: 30px;
background-color: #3c50a2;
line-height: 15px;
color: white;
width: 150px;
z-index: 1000;
}

.slantedButton:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
z-index: -1;
background-color: inherit;
top: 0;
bottom: 0;
right: 0;
left: 0;
transform-origin: top right;
transform: skewY(-4deg);
}
<div class="slantedButton">Hello World!</div>

我尝试用 :before 来做到这一点,但没有成功。

非常感谢您的建议。

非常感谢。

最佳答案

它可以使用 ::before 进行查找。只需更改 transform-origin:

.slantedButton {
position: relative;
box-sizing: border-box;
padding: 5px;
height: 30px;
background-color: #3c50a2;
line-height: 15px;
color: white;
width: 150px;
margin: 30px;
z-index: 1;
}

.slantedButton:before, .slantedButton:after {
position: absolute;
width: 100%;
height: 100%;
content: '';
z-index: -1;
background-color: inherit;
top: 0;
bottom: 0;
right: 0;
left: 0;
}

.slantedButton:before {
transform-origin: top right;
transform: skewY(4deg);
}

.slantedButton:after {
transform-origin: top right;
transform: skewY(-4deg);
}
<div class="slantedButton">Hello World!</div>

关于html - 在顶部和底部创建一个倾斜按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44554524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com