Bootstrap 4 Carousel featuring Shadowed Circles

I am attempting to incorporate two features into a Bootstrap 4 carousel:

1- Add shadow to the text on top of the image in the carousel-caption

2- Display indicators in circular format with numbers inside them

I would like the final result to resemble this image: https://i.sstatic.net/SAfg5.png

This is what I have tried so far:

<script>
/* shadow */
.carousel-caption {
  background: rgba(0,0,0,0.5);
  background-color: rgba(0,0,0,.5);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.85);
}

/* circle indicators and numbers */
.carousel-indicators-numbers {
    li {
      text-indent: 0;
      margin: 0 2px;
      width: 30px;
      height: 30px;
      border: none;
      border-radius: 100%;
      line-height: 30px;
      color: #fff;
      background-color: #999;
      transition: all 0.25s ease;
      &.active, &:hover {
        margin: 0 2px;
        width: 30px;
        height: 30px;
        background-color: #337ab7;        
      }
    }
}
</script>


<!-- carousel NEWS -->
<div class="col-md-9" style="height:550px; width: 900px;">

<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">

  <!-- indicators dot nov -->
  <ol class="carousel-indicators carousel-indicators-numbers">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active">1</li>
    <li data-target="#carousel-example-generic" data-slide-to="1">2</li>
    <li data-target="#carousel-example-generic" data-slide-to="2">3</li>
  </ol>

  <!-- wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="carousel-item active">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 1</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 2</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 3</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
  </div>

  <!-- controls or next and prev buttons -->
  <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>
</div>
</div>

</div>

Unfortunately, my attempts did not yield the desired effect and only show the default Bootstrap carousel layout: https://i.sstatic.net/RxWzS.png

Answer №1

    <style>.carousel-caption {
        background: rgba(0, 0, 0, 0.35);
        width: 100%;
        left: 0;
        padding-top: 0;
        padding-bottom: 0;
        padding-left: 5px;
        padding-right: 5px;
        bottom: 0;
    }
    .carousel-indicators{
        top:15px
    }
    .carousel-indicators li{
        text-indent: 0;
        margin: 0 2px;
        width: 30px;
        height: 30px;
        border: none;
        border-radius: 100%;
        line-height: 30px;
        color: #fff;
        background-color: #999;
        transition: all 0.25s ease;
        padding-left: 10px;
        padding-top: -1px;
    }
    .carousel-indicators li.active, .carousel-indicators li li:hover {
        margin: 0 2px;
        width: 30px;
        height: 30px;
        background-color: #337ab7;
    }</style>

  <div id="demo" class="carousel slide" data-ride="carousel">
        <ul class="carousel-indicators">
            <li data-target="#demo" data-slide-to="0" class="active">1</li>
            <li data-target="#demo" data-slide-to="1" class="">2</li>
            <li data-target="#demo" data-slide-to="2" class="">3</li>
        </ul>

        <div class="carousel-inner">
            <div class="carousel-item active">
                <img src="http://placehold.it/1200x500" alt="..."> 
                <div class="carousel-caption d-block text-center">
                    <h3>Highlighted News Item 1</h3>
                    <p>Discover the latest updates.</p>
                 </div>

            </div>
            
            <div class="carousel-item">
                <img src="http://placehold.it/1200x500" alt="...">      
                <div class="carousel-caption d-block text-center">
                    <h3>Highlighted News Item 2</h3>
                    <p>Learn about recent developments.</p>
                </div>

            </div>
            
            <div class="carousel-item">
                <img src="http://placehold.it/1200x500" alt="...">      
                <div class="carousel-caption d-block text-center">
                    <h3>Highlighted News Item 3</h3>
                    <p>Stay informed on important topics.</p>
                </div>

            </div>

        </div>
        
        <a class="carousel-control-prev" href="#demo" data-slide="prev">
            <span class="carousel-control-prev-icon"></span>
        </a>
        
        <a class="carousel-control-next" href="#demo" data-slide="next">
            <span class="carousel-control-next-icon"></span>
        </a>
    </div>

Answer №2

I have made a change where the CSS code was wrapped inside a script tag and the selection of li elements should be done like this

.carousel-indicators-numbers > li
. Wait for 5 seconds to see the effect on number 1. I'm not sure why it's showing an error.

To achieve the exact same output, I used 0.3 opacity.

<meta name="viewport" content="width=device-width, initial-scale=1">

<!-- carrousel NEWS -->
<div class="col-md-9" style="height:550px; width: 900px;">

<div class="container">
<div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">

  <!-- indicators dot nov -->
  <ol class="carousel-indicators carousel-indicators-numbers">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active">1</li>
    <li data-target="#carousel-example-generic" data-slide-to="1">2</li>
    <li data-target="#carousel-example-generic" data-slide-to="2">3</li>
  </ol>

  <!-- wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="carousel-item active">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 1</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 2</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
    <div class="carousel-item">
        <img class="d-block img-fluid" src="http://placehold.it/850x500" style="width: 850px; height:500px;" alt="Third slide">
        <div class="carousel-caption">
            <a href="#"><h3>News 3</h3></a>
            <p>Bla bla bla bla bla bla bla bla bla bla bla</p>
        </div>
    </div>
  </div>

  <!-- controls or next and prev buttons -->
  <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>
</div>
</div>

</div>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
/* shadow */

.carousel-caption {
  background: rgba(0,0,0,0.3);
  background-color:rgba(0,0,0,.3);
  text-shadow: 0 1px 4px rgba(0, 2, 0, 0.85);
}

/* circle indicators and numbers */
.carousel-indicators-numbers li {
      text-indent: 0;
      margin: 0 2px;
      width: 30px;
      height: 30px;
      border: none;
      border-radius: 100%;
      line-height: 30px;
      color: #fff;
      background-color: #999;
      transition: all 0.25s ease;
      &.active, &:hover {
        margin: 0 2px;
        width: 30px;
        height: 30px;
        background-color: #337ab7;        
      }

}
</style>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Minimum requirement for browsers such as IE9 and other compatible versions

My web app requires IE9 - what are the equivalent browser versions for Firefox, Chrome, Opera, and others? I am able to detect the user's current browser and version, and if it is not compatible, I am considering providing links for them to download ...

ASP.NET file uploads using Ajax - handler unable to detect uploaded files

I am embarking on my first attempt at uploading files through Ajax and .ashx. My browser of choice is FireFox 75.0. Upon inspecting the web console, I set a Breakpoint on frm.append(files[i], files[i].name);. I can see the files being appended to the FormD ...

Leverage the package.json script without relying on any yarn/npm commands

Can scripts commands be executed within the package.json file without needing to include yarn or npm? For example: "scripts": { "get": "node index.js" } Currently, in order to run this script I have to use yarn get [ar ...

Is there a way to remove a function from a constructor in JavaScript?

Is it possible to remove a function from a constructor? If the constructor for a Person object contains a function named greet, how would one go about eliminating this function? function Person(name) { this.name = name; ...

Incorporating Event Tracking Analytics into Your HTML Element: Tag or Div?

I have a button on my website that I want to track in Google Analytics. <div id="contact_btn" class="col-xs-12 col-sm-5"> <a href="{{ ('mailto:' + job.poster.email) if request.authenticated_userid else request.route_path('login_si ...

The ActivatedRoute.routeConfig object appears to be empty in an Angular 2 project built with Angular-cli

Two projects I've created using angular-cli are working perfectly fine. However, in one of them, the routeConfig is showing as null and I can't figure out what's causing this issue. Both projects have identical package.json files, so there ...

What about a Material UI-inspired homepage design?

Looking at the demo image on the main page for Material UI has me really impressed. I am interested in using a similar theme with MUI for my web application. Can you advise me on how I can achieve this look, or do I have to start from scratch? https://i.s ...

Instructions for launching a personalized link within a Progressive Web App on the latest iOS version 16.4

Exciting news with the latest WebKit version 16.4 - now you can enable Web Push notifications on Apple devices with ease. However, there seems to be a glitch I encountered while trying to navigate to a specific page within my Progressive Web App (PWA) when ...

Is it prohibited to use directive class styles in Angular?

I implemented a directive that, upon hovering over an element, adds an overlay to it. Each class in the dynamically added element has 5 to 8 properties, and I want to avoid using HostBinding or setStyle with Renderer2 on the element. Even after adding the ...

How can I eliminate the apostrophe from the hidden field's value using JavaScript?

Currently, I am using JavaScript to read a hidden field value. However, the value I am obtaining is wrapped within single quotes ('78963'). How can I eliminate this single quote and retrieve the value without it (78963)? Any assistance in resolvi ...

Seeking out all of the children associated with their parent using Jquery

Currently, I am utilizing Codeigniter and Jquery in conjunction with the AJAX method to retrieve data from two tables within my database by using a select join operation on the 'group' table and 'cat' table. Below is a description of t ...

While tidying up the code in my home.vue file for my Vue.js project, I am constantly encountering these pesky errors

Compilation failed. ./src/views/Home.vue Error in Module (from ./node_modules/eslint-loader/index.js): C:\Users\OSOKA\Desktop\VUE\vue-shop\src\views\Home.vue 2:21 warning Remove ⏎···⏎·· ...

Is there anyone who can provide guidance on troubleshooting the HttpClient injection error (No provider for http_HttpClient) within an AngularJS/Angular hybrid application?

I've encountered an issue with my hybrid AngularJS/Angular app where the HttpClient module fails to inject (specifically, it shows "No provider for http_HttpClient" error). Interestingly, the deprecated @angular/http module works without any problems. ...

Clear the applied style from a specific DIV element

Currently, I am working on iPhone development and have set up a webview with a DIV element. Within this DIV, I have added 'touchstart', 'touchend', and 'touchmove' events. However, I have noticed that after adding these event ...

Efficiently transferring data in segments within an HTML table using jQuery

My HTML code looks like this: <table id="library_info_tbl"> <thead> <th>Call No.</th> <th>Book</th> <th>Accession No.</th> <th>Status</th> </thead> <tbody& ...

Is there a way to show the message when the username is deemed valid in MVC3?

As part of my database validation process, I am verifying the availability of usernames entered by users. If the username is accepted and available for use, I aim to display a message confirming its validity. ...

Multiple charts experiencing disappearing x-axis labels on Flot

When trying to display two separate bar graphs, the x-axis labels seem to disappear. However, when only one graph is displayed, the labels show up perfectly fine. Any thoughts on why this might be happening? Here is the code snippet for displaying two gr ...

Creating an event listener using a calendar icon

I am looking to create a custom datepicker <input type="text" name="Birth" id="calendarInput" required class="inputField" placeholder="31.12.2001"> <input type="date" name="Birth&qu ...

Browser now replacing attribute translate="yes" with translate="translate"

We have encountered an issue with a translation library that is affecting the functionality of our page. <html lang="en" class="notranslate translated-ltr"> <meta name="google" content="notranslate"> As ...

Validation of dynamically generated name fields using radio button group

CODE: html <form id="myform" type="post"> <fieldset id="myid1"> <input id="entries_8490_burn_id_1" name="entries[8490][burn_id]" value="1" type="radio"/> <input id="entries_8490_burn_id_2" name="entries[8490][burn ...