Reputation: 6461
I would like to use my ::before selector on the bottom of my div box (like in the example image. I was wondering if there is something like an ::under selector?
.direct-chat-text {
border-radius: 5px;
position: relative;
padding: 5px 10px;
background: #d2d6de;
border: 1px solid #d2d6de;
margin: 0px 150px 0 50px;
color: #444444;
}
.direct-chat-text::before {
position: absolute;
right: 100%;
top: 15px;
border: solid transparent;
border-top-width: medium;
border-right-width: medium;
border-bottom-width: medium;
border-left-width: medium;
border-right-color: transparent;
border-right-color: #d2d6de;
content: ' ';
height: 0;
width: 0;
pointer-events: none;
border-width: 6px;
margin-top: -6px;
}
<div class="direct-chat-text">3</div>
Upvotes: 0
Views: 199
Reputation: 4527
There is no ::under pseudo element. There is the ::after.
But it does not matter in the context of your question. To make triangle down shape use border
CSS proberty of any element (or pseudo element). Then postion one. In your case:
.with-under {
border-radius: 5px;
position: relative;
padding: 5px 10px;
background: #d2d6de;
border: 1px solid #d2d6de;
margin: 0px 150px 0 50px;
color: #444444;
}
.with-under::before {
position: absolute;
bottom: -12px;
left: 95%;
margin-left: -6px;
border: 6px solid transparent;
border-top: 6px solid #d2d6de;
content: ' ';
height: 0;
width: 0;
pointer-events: none;
}
<div class="with-under">3</div>
Upvotes: 0
Reputation: 448
.direct-chat-text {
border-radius: 5px;
position: relative;
padding: 5px 10px;
background: #d2d6de;
border: 1px solid #d2d6de;
margin: 0px 150px 0 50px;
color: #444444;
}
.direct-chat-text::before {
position: absolute;
right: 10px;
top: 100%;
width: 0;
height: 0;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-top: 6px solid #d2d6de;
content: '';
pointer-events: none;
}
<div class="direct-chat-text">3</div>
Reference (css shape) : https://css-tricks.com/examples/ShapesOfCSS/
Upvotes: 3
Reputation: 1278
You can try something like this, change left to right and other improvements
.direct-chat-text {
border-radius: 5px;
position: relative;
padding: 5px 10px;
background: #d2d6de;
border: 1px solid #d2d6de;
margin: 0px 150px 0 50px;
color: #444444;
}
.direct-chat-text::before {
position: absolute;
right: 10%;
top: 100%;
border-top: 6px solid #d2d6de;
border-right: 6px solid transparent;
border-bottom: 6px solid transparent;
border-left: 6px solid transparent;
content: ' ';
height: 0;
width: 0;
pointer-events: none;
}
<div class="direct-chat-text">3</div>
Upvotes: 1