Change arrow colors in Bootstraps carousel

后端 未结 13 2056
[愿得一人]
[愿得一人] 2020-12-12 19:25

I\'m obviously missing something stupidly simple here. I have images with a white background so I want to be able to edit the arrows on the Bootstraps Carousel so they are v

相关标签:
13条回答
  • 2020-12-12 20:11

    You should use also: <span><i class="fa fa-angle-left" aria-hidden="true"></i></span> using fontawesome. You have to overwrite the original code. Do the following and you'll be free to customize on CSS:

    <a class="carousel-control-prev" href="#carouselExampleIndicatorsTestim" role="button" data-slide="prev">
        <span><i class="fa fa-angle-left" aria-hidden="true"></i></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="carousel-control-next" href="#carouselExampleIndicatorsTestim" role="button" data-slide="next">
        <span><i class="fa fa-angle-right" aria-hidden="true"></i></span>
        <span class="sr-only">Next</span>
     </a>
    

    The original code

    <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    
    <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
    
    0 讨论(0)
  • 2020-12-12 20:16

    for bootstrap-3 one can use:

    .carousel-control span.glyphicon {
        color: red;
    }
    
    0 讨论(0)
  • 2020-12-12 20:17

    Currently Bootstrap 4 uses a background-image with embbed SVG data info that include the color of the SVG shape. Something like:

    .carousel-control-prev-icon { background-image:url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23fff' viewBox='0 0 8 8'%3E%3Cpath d='M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z'/%3E%3C/svg%3E"); }
    

    Note the part about fill='%23fff' it fills the shape with a color, in this case #fff (white), for red simply replace with #f00

    Finally, it is safe to include this (same change for next-icon):

    .carousel-control-prev-icon {background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23f00' viewBox='0 0 8 8'%3E%3Cpath d='M5.25 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z'/%3E%3C/svg%3E"); }
    
    0 讨论(0)
  • 2020-12-12 20:20

    To customize the colors for the carousel controls, captions, and indicators using Sass you can include these variables

        $carousel-control-color: 
        $carousel-caption-color: 
        $carousel-indicator-active-bg: 
    
    0 讨论(0)
  • 2020-12-12 20:21

    If you just want to make them black in Bootstrap 4+.

    .carousel-control-next,
    .carousel-control-prev /*, .carousel-indicators */ {
        filter: invert(100%);
    }
    
    0 讨论(0)
  • 2020-12-12 20:23

    This worked for me:

    .carousel-control-prev-icon {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath d='M5.25 0l-4 4 4 4 1.5-1.5L4.25 4l2.5-2.5L5.25 0z'/%3e%3c/svg%3e");
          }
          
          .carousel-control-next-icon {
            background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='%23000' width='8' height='8' viewBox='0 0 8 8'%3e%3cpath d='M2.75 0l-1.5 1.5L3.75 4l-2.5 2.5L2.75 8l4-4-4-4z'/%3e%3c/svg%3e");
          }
    

    I changed the color in the url of the icon. Thats the original that is used in the bootstrap page but with this section in black:

    "...fill='%23000'..."

    0 讨论(0)
提交回复
热议问题