You can use the combination of position: relative
with position: absolute
next to a pseudo element like :before
or :after
, similar to the one I answered How to make the button tilted?
In this example I removed the pseudo element :after
(we only need one, in this case the :before
) you will also need to change border-top
to border-bottom
if you want tilt to end at the top of the button. p>
If you want the slope of the left side (here you should set border-bottom
as height
, ie both should be the same size):
.botao {
border: none; /*remove borda do elemento button*/
color: #fff;
position: relative;/*faz os elementos pseudos acompanharem o elemento com a classe*/
display: inline-block;
background-color: #CC0000;
line-height: 20px; /*Centraliza o texto*/
height: 20px;
padding:0 10px;
margin: 0 10px;
}
.botao:before {
content: "";
width: 0px;
height: 0px;
top: 0px;
position: absolute;
border-bottom: 20px solid transparent;
border-right: 15px solid #CC0000;
left: -15px;
}
<button class="botao">tag BUTTON</button>
<div class="botao">tag DIV</div>
If you want the slope of the right side, change right:
by left:
and border-right
by border-left
within the pseudo element (here you must set border-top
as height
, that is, both should be the same size):
.botao {
border: none; /*remove borda do elemento button*/
color: #fff;
position: relative;/*faz os elementos pseudos acompanharem o elemento com a classe*/
display: inline-block;
background-color: #CC0000;
line-height: 20px; /*Centraliza o texto*/
text-align: center;
height: 20px;
padding:0 10px;
margin: 0 10px;
}
.botao:before {
content: "";
width: 0px;
height: 0px;
top: 0px;
position: absolute;
border-bottom: 20px solid transparent;
border-left: 15px solid #CC0000;
right: -15px;
}
<button class="botao">tag BUTTON</button>
<div class="botao">tag DIV</div>
Applying the effect very close to what you expect:
.botao {
border: none; /*remove borda do elemento button*/
color: #fff;
font-size: 14pt;
font-weight: bold;
position: relative;/*faz os elementos pseudos acompanharem o elemento com a classe*/
display: inline-block;
background-color: #DC005E;
line-height: 65px; /*Centraliza o texto*/
text-align: center;
height: 65px;
margin-left: 20px;
width: 260px;
}
.botao:before {
content: "";
width: 0px;
height: 0px;
top: 0px;
position: absolute;
border-bottom: 65px solid transparent;
border-right: 20px solid #DC005E;
left: -20px;
}
<button class="botao">tag BUTTON</button>
<div class="botao">tag DIV</div>