0

I have a bootstrap carousel, that adds the image inline in each carousel-item, and this background image needs to be .4 opacity. But the caption of this carousel-item needs to be 1 opacity. Is there any way i can do this?

    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
        <div class="carousel-inner" role="listbox">

            <!-- Slide One - Set the background image for this slide in the line below -->
            <div class="carousel-item active" style="background-image: url('img/banner.jpg')">
                <div class="carousel-caption d-none d-md-block">
                    <h2 class="display-4">First Slide</h2>
                    <p class="lead">This is a description for the first slide.</p>
                </div>
            </div>

        </div>
    </div>
Tiago P.C
  • 99
  • 2
  • 11

1 Answers1

0

Opacity has a default initial value of 1. Opacity is not inherited, but because the parent has opacity that applies to everything within it. You cannot make a child element less transparent than the parent, without some tricks

the child element would not stay as child just change it's position on your html code and then just add css property on that previous child:

.child {
    position : relative;
    top : 5rem;
}
.parent {
    opacity : 0;
}

I hope this would be useful