Reputation: 145
I have some text on top of my images for my carousel shown below.
I want to add a box around the text with some opacity so it is easier to read. I've tried some things but the box takes a weird shape as it starts to scale down.
Here is my html for my Carousel:
<!-- Carousel -->
<header id="myCarousel" class="carousel slide carousel-fade" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for Slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<!-- Set the first background image using inline CSS below. -->
<img src="img/golden_egg3.jpg" class="img-responsive first-slide" alt="First slide">
<div class="container">
<div class="carousel-caption">
<div class="caption-one">
<h1>The right Wealth Advisor can make a big difference.</h1>
<br>
<a href="contact.html" class="btn btn-primary btn-lg hvr-underline-from-left" role="button">Learn More</a>
</div>
</div>
</div>
</div>
<div class="item">
<!-- Set the first background image using inline CSS below. -->
<img src="img/graph_in_hand3.jpg" class="img-responsive second-slide" alt="Second slide">
<div class="container">
<div class="carousel-caption">
<div class="caption-two">
<h1>Personal Wealth Planning is not<br> just charts and graphs, it's about<br> taking control of your financial future.</h1>
<a class="btn btn-lg btn-primary hvr-underline-from-left" href="contact.html" role="button">Learn More</a>
</div>
</div>
</div>
</div>
<div class="item">
<!-- Set the first background image using inline CSS below. -->
<img src="img/jar_with_coins3.jpg" class="img-responsive third-slide" alt="Third slide">
<div class="container">
<div class="carousel-caption">
<div class="caption-three">
<h1>Successful investing takes<br> time, discipline and patience.</h1>
<a class="btn btn-lg btn-primary hvr-underline-from-left" href="contact.html" role="button">Learn More</a>
</div>
</div>
</div>
</div>
</div>
<a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</header>
For my class .caption-one
which is my first image I applied the following CSS:
.caption-one {
background-color: #282828;
opacity: 0.75;
padding-left: 2%;
margin-right: 38%;
padding-bottom: 2%;
width: 40%;
}
And this is what I get:
Looks okay but definitely could be better. Here it is on mobile:
Even worse. I have no clue why my button is so big because I use this same button for the contact page and it scales very nicely. Any help is much appreciated.
Upvotes: 1
Views: 3168
Reputation: 766
I made some changes to your code, Hope this work.
.carousel-caption{
background-color: #282828;
opacity: 0.75;
}
@media(max-width: 768px){
h1{
font-size: 14px;
}
}
<div class="container">
<div class="carousel-caption">
<h1>The right Wealth Advisor can make a big difference.</h1>
<br>
<a href="contact.html" class="btn btn-primary btn-lg hvr-underline-from-left" role="button">Learn More</a>
</div>
</div>
Upvotes: 1