Ways to customize the color surrounding a slider image with the help of Bootstrap

I just started working with bootstrap design, and I encountered an issue with my slider images. There is a gray color around the slider images that I want to change, but my attempts are not yielding results. Here is what I tried: https://i.sstatic.net/xnsFK.jpg

The area highlighted in yellow is where I want to add a different color. mainPage.html

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Your Online Store</title>
    <!-- Add Bootstrap CSS -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
    <!-- Add your custom CSS -->
    <link rel="stylesheet" th:href="@{/css/mainPage.css}" />
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light">
    //code of navbar
</nav>

<!-- Hero Section -->
<header class="jumbotron text-center">
    <div class="container slider-container">
        <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
            <ol class="carousel-indicators">
                <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
                <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
                <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
            </ol>
            <div class="carousel-inner">
                <div class="carousel-item active">
                    <img class="d-block w-100" th:src="@{/images/pairShoe.jpg}" alt="First slide">
                </div>
                <div class="carousel-item">
                    <img class="d-block w-100" th:src="@{/images/shoestext.jpg}" alt="Second slide">
                </div>
                <div class="carousel-item">
                    <img class="d-block w-100" th:src="@{/images/printTshirt.jpg}" alt="Third slide">
                </div>
                <div class="carousel-item">
                    <img class="d-block w-100" th:src="@{/images/jeenspieces.jpg}" alt="Third slide">
                </div>
            </div>
            <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>
</header>

<!-- rest code -->

</body>
</html>

mainPage.css

.slider-container {
    background-color: #005CAF;
}

The above code is not changing the background color in the yellow marked area as intended.

Answer №1

The highlighted yellow portion you are seeing is actually the padding surrounding your header element. In order to change the color of this area, I modified the "jumbotron" class within mainPage.css instead of targeting the "slider-container" div element.

.jumbotron {
    background-color: #005CAF;
}

If you still want to select the div, you can also add vertical padding to it like so:

.slider-container {
    background-color: #005CAF;
    padding: 50px 0px;
}

I hope this explanation helps clarify things for you!

Answer №2

.page-header {
  background-color: purple !important;
}
.carousel-container {
  background-color: #8B008B;
}

Make sure to set the background-color for your main header element as needed for proper execution of your code.

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

Can a JavaScript function be used with images to operate across multiple elements?

How can I make a function work on multiple elements? let image = document.getElementById("opacityLink"); image.onmouseover = function() { image.style = "opacity:0.9"; }; image.onmouseout = function() { image.style = "opacity:1"; }; <div class=" ...

an issue encountered while trying to print a webpage styled with CSS

Users are given the option to print the current page on the website by clicking on a menu element: <li> <a href="#" onClick="window.print()"> <i class="icon-print"></i> Print Page </a> </li> The page contai ...

Looking to modify the button's background color when it is clicked using either Javascript or jQuery?

I have 2 buttons with class df-button and df-web-design - I want to change the background color of only the clicked button when it is clicked, and then when the other button is clicked, the background should return to its default color. I am looking to ach ...

Post the information from a webpage onto your Instagram story

I'm currently developing a web application that generates text content, with future plans to include images as well. I want to integrate a share button that allows users to easily add this generated content to their Instagram story. The intended flow ...

Are JQuery event names a secure choice for class names within your code base?

While testing a remote site, I encountered an issue where the click event for an element is not functioning properly in certain Windows environments running Internet Explorer and Safari. I've observed that elements with a clickable function have a cl ...

Tips for maintaining variable values when invoking PHP functions

After setting a global variable value in a PHP functions file and successfully using it within one PHP file, I encountered an issue when trying to access the same variable from another PHP file using include("functions.php"). This is the process I followe ...

Transpiling Sccs/Sass code into CSS

Is there a way to create a compiler that can convert SCCS/SASS code into CSS without using a VSCode extension? I'm curious about what programming language and basic concepts are needed for this task. Any insights would be greatly appreciated. Thanks! ...

Is there a way to keep a div element stationary during scrolling without using fixed positioning?

Is there a way to prevent a div from moving when scrolling up or down without using the position:fixed property? When an element is fixed, the scroll bar disappears making it impossible to reach the element by scrolling. div{ position:fixed; top:1 ...

Set up an event listener for all buttons to detect clicks, and proceed to initiate an AJAX request to

Looking for a way to incorporate jQuery into my HTML code. Specifically, I want to create a function that triggers an Ajax post request to retrieve the value of an iframe and append it to the following div: <div id = "contenedorFrame"></div> ...

retrieve the month and year data from the input date

I encountered a situation where I'm working with the following unique HTML code: <input type="date" id="myDate"/> <button type="button" class="btn btn-secondary" id="clickMe">MyButton</ ...

I would like to know how to create a dropdown menu that shows the country name, flag, and code based on the

I have successfully generated the telephone input field. One requirement is to display the Country flag along with the country name as soon as the dropdown is selected. Another requirement is that once the country is selected, it should display the countr ...

Enhance your browsing experience by inputting valuable information into the

I am looking to enhance a text box by adding values. The text box already has a default value of 10, and I want to create a button that will add new text boxes with a limit of 4. My goal is to continuously add values from text box 1 to text box 4. For exa ...

Load information from a JavaScript object when the user clicks dynamically

My challenge involves utilizing a JavaScript object that contains video information such as title and source URL. Within my HTML, I have image placeholders and the goal is to trigger a modal pop-up (using Twitter Bootstrap modal) of the specific video when ...

Eliminating render-blocking CSS in PageSpeed - one stylesheet at a time

Currently, I am testing the best optimization practices for front-end development. As part of this process, I have utilized gulp and npm to merge and minify my CSS and JS files into a single all.min.css and js.min.css file. Upon analyzing my website using ...

Creating a layered effect: Adding an image onto another image using HTML and CSS

Wondering if it's possible to create an overlaid effect with an image and text inside of an <img> element, similar to the example image below. Utilizing Bootstrap for this design. This is how I am attempting to achieve it: HTML <div class= ...

Is it possible to retrieve the value of this input field within a function call in HTML?

When working with an HTML input field, I encountered the need to limit manual input to 100. Although I already had minimum and maximum values set up for spinner functionality (up and down arrows), I wanted to create a reusable function instead of using inl ...

Having difficulties loading my stylus stylesheet onto my jade HTML page using expressjs

Within my express application, I am attempting to load the style properties from a styles module engine. Unfortunately, I am facing difficulties in loading my style. Here is the structure of my folders: myNodeApp -node_modules -styles - ...

What is causing the <iframe> to malfunction when I use it?

I am encountering a problem with a basic snippet of HTML code: <!doctype html> <html lang="en"> <head> <meta charset="UTF-8> <title>iframe Example</title> </head> <body> <div> & ...

What is the most effective method for embedding a Kotlin program into a website?

I have created a combat simulation tool in Kotlin for an online gaming community. Users can input the combat levels of two players, choose the number of duels to simulate, and then initiate the simulation which will provide win percentages and other stats. ...

Show the JSON information found on a specific website URL

I need help figuring out how to display a json file on a web address so that Swagger UI can recognize it. When I visit , I see json data and can save it as a .json file. However, I'm struggling to replicate this using html. Here's what I've ...