Below, I would like to create the following effect on a button element in CSS:
Whereas I just want a basic regular button but with the 'tab' sticking out of the bottom.
How do I do this?
I've tried ::after
and ::before
, but neither even show any results for some reason (and I don't really know how to use those rules either).
.button {
background: #aaa;
font-size: 16px;
color: #000;
padding: 8px;
width: 200px;
border: 3px solid #000;
border-radius: 6px;
}
.button::after {
width: 10px;
height: 100px;
background: #aaa;
}
<button class="button">BUTTON</button>
You're on the right track with ::after
You need to include content
in ::after
, even if empty.
You have to set position: relative
on the button and position: absolute
on the pseudo-element so it can be placed outside the button.
You also didn’t tell the browser where to actually put the ::after
element (like bottom
, left
, etc.).
.button {
position: relative;
background: #aaa;
font-size: 16px;
color: #000;
padding: 8px;
width: 200px;
border: 3px solid #000;
border-radius: 6px;
text-align: center;
}
.button::after {
content: "";
position: absolute;
bottom: -10px;
left: 50%;
transform: translateX(-50%);
width: 80px;
height: 7px;
background: #aaa;
border-left: 3px solid #000;
border-right: 3px solid #000;
border-bottom: 3px solid #000;
border-radius: 0 0 6px 6px;
}