What is the best way to add an image on a personalized carousel?

I am working with a customized carousel that I found here. My goal is to place an image in the top left corner of the carousel.

Despite extensive research, I have been unable to find a solution that doesn't distort my carousel.


    <!-- Carousel -->
    <header>
                <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
                  <ol class="carousel-indicators">
                    <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="0" class="active"></li>
                    <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="1"></li>
                    <li data-target="#carouselExampleIndicators" data-target="#mycarousel" data-slide-to="2"></li>
                  </ol>
                  <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('images/c1.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>
                    <!-- Slide Two - Set the background image for this slide in the line below -->
                    <div class="carousel-item" style="background-image: url('images/c2.jpg')">
                      <div class="carousel-caption d-none d-md-block">
                        <h2 class="display-4">Second Slide</h2>
                        <p class="lead">This is a description for the second slide.</p>
                      </div>
                    </div>
                    <!-- Slide Three - Set the background image for this slide in the line below -->
                    <div class="carousel-item" style="background-image: url('images/c3.jpg')">
                      <div class="carousel-caption d-none d-md-block">
                        <h2 class="display-4">Third Slide</h2>
                        <p class="lead">This is a description for the third slide.</p>
                      </div>
                    </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>
              </header>

    <div class="logo">
                    <img src="images/logo.png">
                </div>

    /* css */
    .carousel-item {
        height: 100vh;
        min-height: 350px;
        background: no-repeat center center scroll;
        -webkit-background-size: cover;
        -moz-background-size: cover;
        -o-background-size: cover;
        background-size: cover;
      }

    #logo{
        position: absolute;
        top: 0;
        left: 0;
    }

The issue I'm facing is that the image appears underneath the carousel instead of overlaying it.

jfiddle

Answer №1

Utilizing a class for the logo in your HTML code and an ID selector in CSS is the best practice.

This would result in the following code:

.logo {
    .....
}

rather than

#logo {
    .....
}

Answer №2

Ensure that the parent element is positioned correctly by wrapping the code in a container and giving the container a relative position. This will allow the child div with the image to behave as expected. Alternatively, you can place the div inside the header so that the logo div becomes a child of the header.

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

Adding a class to an element can be easily achieved when both input fields have values

Is it possible to apply the "active" class to the element go_back_right only when both inputs with classes search_box_name and search_box_id have content in them? I've tried looking for solutions on this platform, but being new to JavaScript, I couldn ...

The blur effect isn't functional on the Firefox internet browser

When using the blur filter in my React application, everything works fine in Google Chrome and Microsoft Edge. However, I encountered an issue when testing it in Mozilla Firefox. Despite checking mozilla.org for solutions, I couldn't find anything spe ...

I am unable to insert an HTML horizontal rule

Currently, I am attempting to separate the sections in my tablet, but I am facing difficulty adding a dividing line. When I try to add style = "border: 1px solid black" in the tr section, it shows up but not in the desired manner. The code snippet is as f ...

Challenges arise when arranging div boxes vertically

Here is my code snippet: .blueleft { background-color: white; width: 300px; border: 25px #cee2e8; padding: 25px; margin: 40px; float: left; font-family: "berlin sans fb"; color: gray; font-size: 20px; text-align: c ...

Scrollbar styling functions flawlessly on Chrome and Safari, but encounters issues on Mozilla Firefox

Currently, the scrollbar is functioning properly in Chrome and Safari, but in Mozilla, it is not behaving as expected. Below, you can find my code. Although using jquery or JavaScript would be a quick solution, I am exploring CSS options first. ::-webki ...

Creating an HTML button to reveal additional text on the same page

Currently, I am working on a project involving html and javascript. My issue lies in displaying multiple options on the same webpage without switching pages. Essentially, I have a plot and a few buttons on one page, and when a user clicks on any of these b ...

Is it possible to have individual submit buttons on forms that instruct the form where to post its "action" to different files?

I have decided to enhance my form by incorporating an extra Submit button for a specific purpose. User will make a selection User will click on the "Add another item" Submit button within the form. The form will then POST to itself and reload the page, a ...

Implementing a background image layered over a background color using CSS

Currently, I am in the process of converting a webpage from PSD format. The main content of the page is designed with a solid background color, but there is also a separate layer that features a glow effect on top of the background. However, when implement ...

What is the process for showing and hiding text when a div is clicked?

Hey, I'm completely new to web development and decided to practice some of the concepts I've been learning about. I created a simple program that toggles between day and night. Clicking on the sun reveals the moon, and clicking on the moon revea ...

html and css code to create a linebreak ↵

I received a JSON response from the server, and within this data is a "return line" in the text. {text: "I appear in the first line ↵ and I appear in the second line"} However, when I try to display this on an HTML page, the "return line" does not show ...

In IE8, CSS classes assigned to HTML5 elements are removed when they are printed

Currently, I am facing a challenge where I need to ensure proper printing functionality in IE8. The issue arises when using HTML5 features (such as sections) along with CSS on a page - the problem occurs specifically during printing. For example, when tryi ...

Html - The 'td' element in the table is not staying fixed

In my project, I have created a table with Start date and End Date as two table data elements. I have implemented some validations that are triggered when certain conditions are not met. However, I noticed that when these validations are fired, it causes t ...

Activating development mode for LessCSS in Node.js

I'm encountering some major difficulties identifying LESS parse errors within a large CSS compilation. The error messages aren't providing much help (at least not for me). Here are my questions: 1. Is there a method to activate more debugging ...

Issues with Media Query in Mobile Device Footer not Resolving

Despite searching through numerous pages on Stack, I have not been able to find a solution. I am attempting to remove the footer on mobile devices using a media query. Unfortunately, it does not seem to be effective on the device, although it works when th ...

problem with selection of date and month in dropdown list with jquery

Recently, I've been dabbling in jQuery and decided to create two list boxes using it. One box contains dates while the other contains months. It's quite handy since I need them in different sections of my HTML page. However, when attempting to en ...

Clickable image in HTML that sends a request to an ActionResult

In my MVC project, I am attempting to create an HTML image button within a search box that will redirect to an ActionResult. My current setup looks like this: <input type="text" id="Text1" name="seachKeyword" class="searchTextBox" value="Search" style ...

What is the best way to eliminate data from a channel title using jQuery?

$(function() { $(".track").draggable({ containment:"document", appendTo:document.body, connectToSortable:"#playlist tbody", revert: true, revertDuration: 0, cursor: "move", helper: "clone", ...

Tips for incorporating background color with CSS pseudo-elements

I'm attempting to replicate the outcome shown in the screenshot but I'm having difficulty achieving it without adding any new DOM elements. When I click on the demo link and choose a date range, the start date and end date selections are not dis ...

In ASP.NET MVC, use CSS styling specifically for Partial Views by encapsulating the styles within a `<style scoped>` tag

A new HTML attribute has emerged, known as scoped, however, it is currently only supported by Firefox. This attribute allows you to declare internal styles solely for the parent element. I am curious if it is feasible to replicate this functionality in AS ...