倾斜变换后去除边框一侧的背景轮廓
Remove background outline on the side of the border after skew transform
HTML:
<div class="labels">
<p>Very Funny</p>
</div>
CSS:
div.labels p {
background: red;
border-left: 2rem solid white;
border-right: 2rem solid white;
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
-webkit-text-stroke: 2px white;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
这是演示:https://jsfiddle.net/90vLp4ub/
您会注意到由于背景原因,元素周围有一条细红线。我怎样才能摆脱它?
谢谢。
只需删除左右边距即可。他们负责那些红色轮廓
div.labels p:hover {
background: red !important;
border-left: 2rem;
border-right: 2rem;
}
div.labels p {
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
margin: 0 auto;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
<div class="labels">
<p>Very Funny</p>
</div>
要去除红色轮廓并保留动画,您可以这样做:
- 移除 p:hover
的左右边框
- 添加一些margin-left
div.labels p:hover {
background: red !important;
margin-left: 30px;
}
div.labels p {
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
-webkit-text-stroke: 2px white;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
<div class="labels">
<p>Very Funny</p>
</div>
HTML:
<div class="labels">
<p>Very Funny</p>
</div>
CSS:
div.labels p {
background: red;
border-left: 2rem solid white;
border-right: 2rem solid white;
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
-webkit-text-stroke: 2px white;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
这是演示:https://jsfiddle.net/90vLp4ub/
您会注意到由于背景原因,元素周围有一条细红线。我怎样才能摆脱它?
谢谢。
只需删除左右边距即可。他们负责那些红色轮廓
div.labels p:hover {
background: red !important;
border-left: 2rem;
border-right: 2rem;
}
div.labels p {
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
margin: 0 auto;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
<div class="labels">
<p>Very Funny</p>
</div>
要去除红色轮廓并保留动画,您可以这样做:
- 移除 p:hover 的左右边框
- 添加一些margin-left
div.labels p:hover {
background: red !important;
margin-left: 30px;
}
div.labels p {
color: white;
font-family: 'Bebas Neue';
text-transform: uppercase;
line-height: 0.8;
transition: 0.4s ease all;
font-size: 4rem;
-webkit-text-stroke: 2px white;
letter-spacing: 2px;
width: fit-content;
padding: 1rem 2rem;
transform: skew(-10deg);
}
<div class="labels">
<p>Very Funny</p>
</div>