Reputation: 103
I would to replicate this : http://prntscr.com/k5wp2t I try with this code, but I need help to set it better.
<div class="button">MAGGIORI INFORMAZIONI</div>
.button {
position: relative;
display: block;
width: 120px;
height: 50px;
background: blue;
}
.button:after{
position: absolute;
bottom: 0;
height: 0;
width: 0;
left: 30%;
border: 30px solid transparent;
border-bottom-color: red;
content: "";
}
thanks
Upvotes: 3
Views: 5889
Reputation: 3819
You can also use a gradient background:
background: linear-gradient(135deg, #F47E3E 220px,#000 0);
.button {
position: relative;
display: block;
width: 270px;
padding: 20px;
background: linear-gradient(135deg, #F47E3E 220px,#000 0);
display: flex;
align-items: center;
justify-content: center;
color: #FFF;
}
<div class="button">RICHIEDI INFORMAZIONI</div>
Upvotes: 1
Reputation: 76
Please use this css code
.button {
position: relative;
display: block;
width: 120px;
height: 50px;
background: blue;
padding-right: 40px;
overflow: hidden;
color:#fff;
padding-left:30px;
line-height:22px;
}
.button:after{
position: absolute;
bottom: 0;
height: 50px;
width: 30px;
right: -14px;
background: red;
content: "";
z-index: 1000;
transform: skew(-30deg);
}
Upvotes: 1
Reputation: 1631
Please use this
.button {
position: relative;
display: block;
width: 120px;
height: 50px;
background: blue;
padding-right: 40px;
overflow: hidden;
color:#fff;
padding-left:30px;
line-height:22px;
}
.button:after{
position: absolute;
bottom: 0;
height: 50px;
width: 30px;
right: -14px;
background: red;
content: "";
z-index: 1000;
transform: skew(-30deg);
}
<div class="button">MAGGIORI INFORMAZIONI</div>
Upvotes: 2
Reputation: 1239
You need to set border-left to transparent to have such a shape & move it to right as 0px.
You can also refer to this really good article on Shape using CSS here at (Shape of CSS)[https://css-tricks.com/examples/ShapesOfCSS/]
.button {
position: relative;
display: block;
width: 270px;
padding: 20px;
background: #F47E3E;
display: flex;
align-items: center;
justify-content: center;
color: #FFF;
}
.button:after {
position: absolute;
bottom: 0;
right: 0px;
border-bottom: 62px solid red;
border-left: 62px solid transparent;
border-bottom-color: #000;
content: "";
}
<div class="button">MAGGIORI INFORMAZIONI</div>
Upvotes: 0
Reputation: 2676
To make it a real triangle, you need to also have color on the right side, with border-right-color: red;
. After that, remember to make sure the triangle is the same size as the button (the button has height: 50px;, so the borders should be 25px - not 30), and position it to the right, and not 30% from the left.
.button {
position: relative;
display: block;
width: 120px;
height: 50px;
background: blue;
}
.button:after{
position: absolute;
bottom: 0;
height: 0;
width: 0;
right:0;
border: 25px solid transparent;
border-bottom-color: red;
border-right-color: red;
content: "";
}
Upvotes: 1