27
  <div class="  affix  popover right" id ="one" style="margin-left:8em;margin-top:10em;  width:15em;background-color:rgba(228,19,47,0.9);padding:5px;border-radius:10px;">
    <div class="arrow" style="margin-top:-45px;"></div> 
    <center style="padding:20px;"><b>this is the message</b></center>
 </div>

This code creates the popover with a arrow how can we change the color of this arrow.

enter image description here

Antony
  • 14,900
  • 10
  • 46
  • 74
dpndra
  • 2,098
  • 4
  • 23
  • 29
  • look at this answer: http://stackoverflow.com/a/38279489/3554107. For styling each directional arrows, we have to select each arrow using CSS attribute selector and then style them individually. – vishnu Jul 09 '16 at 07:42
  • Possible duplicate of [Styling the arrow on bootstrap tooltips](http://stackoverflow.com/questions/15383440/styling-the-arrow-on-bootstrap-tooltips) – vishnu Jul 09 '16 at 07:42

11 Answers11

43

Use this css changing border-right color of pseudo element:

.popover.right .arrow:after {
  border-right-color: red;
}

#DEMO

Alex Stephens
  • 3,017
  • 1
  • 36
  • 41
Manwal
  • 23,450
  • 12
  • 63
  • 93
5

In Bootstrap 4,

.bs-popover-top .arrow::after,
.bs-popover-auto[x-placement^="top"] .arrow::after {
    border-top-color: yellow; // Any color here
}
KimchiMan
  • 4,836
  • 6
  • 35
  • 41
  • Seems to work fine without the second identifier ".bs-popover-auto[x-placement^="top"] .arrow::after". Is there something I'm not aware off that this should be required? – tdahman1325 Mar 04 '21 at 14:16
4

Using a standard popover in Bootstrap 3, as in:

<button type="button" class="btn btn-default" data-toggle="popover" data-placement="right" data-content="this is the message">
  Popover on right
</button>

You can add the following css to your custom rules:

.popover {
  background-color: red; /*substitute 'red' with your color of choice*/
  border-color: red;
}
.popover.right>.arrow:after {
  border-right-color: red;
}
.popover-content {
  background-color: red;
}
jme11
  • 17,134
  • 2
  • 38
  • 48
4

I found out that you need to override one class for each of the possible positions of the popover. In this example, my "tour" popover has a dark background and white text:

.popover[class*=tour-] {
    background: #434A54;
    color: white;
}

/* Needed to have the triangle match the grey background of the popover */
.popover[class*=tour-].top .arrow:after {
    border-top-color: #434A54;
}

.popover[class*=tour-].right .arrow:after {
    border-right-color: #434A54;
}

.popover[class*=tour-].bottom .arrow:after {
    border-bottom-color: #434A54;
}

.popover[class*=tour-].right .arrow:after {
    border-left-color: #434A54;
}
MSC
  • 3,286
  • 5
  • 29
  • 47
2

[Bootstrap Popover with arrow and background color]

.popover{
   background: #ebd997;
    height: 100px;
    width: 500px;
}

.popover.top> .arrow:after {
    border-top-color: #ebd997;
}
Popeye
  • 253
  • 4
  • 13
1

Not sure on this, but you can try changing

<div class="arrow" style="margin-top:-45px;"></div> 

to

<div class="arrow" style="margin-top:-45px; color: red;"></div> 

Hope this helps.

Regards, Alex

Alex Szabo
  • 3,274
  • 2
  • 18
  • 30
1

With using bootstrap 4 popover template

template: "<div class=" popover yellow" role="tooltip"><div class="arrow"></div><div class="popover-body"></div></div>"



.yellow .arrow::after {
        border-top-color: black;
        border-bottom-color: black;
    }
Bilal Mohammed
  • 139
  • 1
  • 5
1

In Bootstrap 5:

.popover .popover-arrow:after {
  border-top-color: red;
}

.popover .popover-arrow:after {
  border-bottom-color: red;
}

.popover .popover-arrow:after {
  border-left-color: red;
}

.popover .popover-arrow:after {
  border-right-color: red;
}
jenkin
  • 11
  • 1
0

If your using Angular2/4/5, with NGX-Bootstrap I manage to change it with CSS, click on normal text to popover on top. The others do not work because container="body" is not used. in angular they create [_nghost-c0] if you use container="body".

  :host /deep/.popover.top > .arrow:after 
{
     border-top-color: red;
}
:host/deep/.curvepopover{
    border-radius:10px;
    border:4px solid red;
    
}
  
GoodJeans
  • 370
  • 7
  • 18
0
.bs-popover-top .arrow::after,
.bs-popover-auto[x-placement^="top"] .arrow::after {
    border-top-color: $blue; // Any color here
}

.bs-popover-bottom .arrow::after,
.bs-popover-auto[x-placement^="bottom"] .arrow::after {
    border-bottom-color: $blue; // Any color here
}
raklos
  • 28,027
  • 60
  • 183
  • 301
0

In Bootstrap 5:

.bs-popover-top .popover-arrow:after {
    border-top-color: red;
}

.bs-popover-bottom .popover-arrow:after {
    border-bottom-color: red;
}

.bs-popover-start .popover-arrow:after {
    border-left-color: red;
}

.bs-popover-end .popover-arrow:after {
    border-right-color: red;
}
Rick Mohr
  • 1,821
  • 1
  • 19
  • 22