0

I want to create a comment box with bottom arrow. But I don't know how to add this arrow. This is the model that I want to create.

enter image description here

This is my code so far.

.arrow-div {
    position: relative;
    background: #424242;
    margin: 2em auto;
    color:#eaeaea;
    border-radius:3px;
    height: 2.5em;
    text-align:center;
    width:270px;
 }
<div class="arrow-div">
$167 still needed for this project
</div>
Mel
  • 5,837
  • 10
  • 37
  • 42
Chathuri Fernando
  • 950
  • 3
  • 11
  • 22
  • If you want the arrow to be horizontally centered relative to the remaining empty progress bar, you probably need JS to adjust it's final position. For the markup, look at [using pseudo-elements to create an arrow element](https://css-tricks.com/snippets/css/css-triangle/). – Terry Sep 15 '17 at 11:52

1 Answers1

5

You can use the :before pseudo-selector:

.arrow-div {
    position: relative;
    background: #424242;
    display:flex;
    align-items: center;
    justify-content:center;
    margin: 2em auto;
    color:#eaeaea;
    border-radius:3px;
    height: 2.5em;
    width:270px;
 }
 
 .arrow-div:before
 {
    content: '';
    position: absolute;
    bottom:-7px; right: 20px;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 7.5px 0 7.5px;
    border-color: #042424 transparent transparent transparent;
 }
<div class="arrow-div">
  <p>Blah Blah content...</p>
</div>
Yashwardhan Pauranik
  • 5,370
  • 5
  • 42
  • 65
G.Hunt
  • 1,364
  • 10
  • 20