我正在制作一个右侧偏斜的形状。
以下是代码:
h2 {
display: inline-block;
position: relative;
text-transform: uppercase;
background: #2b4450;
color: white;
font: bold 16.67px'Raleway', sans-serif;
padding: 0 35px;
height: 35px;
line-height: 35px;
cursor: pointer;
}
h2:before {
content: '';
position: absolute;
right: 0;
top: 0;
bottom: 0;
width: 34px;
transform-origin: right top;
transform: skew(30deg) translate3d(0, 0, 0);
background: inherit;
}
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
在Chrome和Firefox中看起来不错,但不是IE。在IE中,伪元素向上移动约0.5px,有时向下移动0.5px,这就是它的外观:
有什么建议吗?
答案 0 :(得分:1)
如果选项是边框:https://jsfiddle.net/3nmha5sf/9/
<强> HTML 强>
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
<br/>
<br/>
<h2>ALL CAMPAIGNS</h2>
<强> SCSS 强>
h2 {
display: inline-block;
position: relative;
text-transform: uppercase;
background: #2b4450;
color: white;
font: bold 16.67px 'Raleway', sans-serif;
padding: 0 35px;
height: 35px;
line-height: 35px;
cursor: pointer;
&:after {
content: '';
position: absolute;
right: -20px;
bottom: 0;
width: 0;
background: none;
height: 0;
border: solid transparent;
border-bottom-color: #2b4450;
border-width: 0 20px 35px;
}
}