Adding text and buttons to the initial image in the slider: a step-by-step guide

I'm facing an issue with my html image slider as I try to add buttons and text to the first image but it keeps getting overridden.

<div id="captioned-gallery">
    <figure class="slider">
      <figure> 
        <img src="images/multipurpose.jpg"> 
      </figure>
      <figure>
        <img src="images/sanitizer.jpg" alt>  
      </figure>
      <figure>
        <img src="images/glycerine.jpg" alt>       
      </figure>
      <figure>
        <img src="images/multipurpose.jpg" alt> 
      </figure>
      <figure>
        <img src="images/sanitizer.jpg" alt> 
      </figure>
   </figure>
 </div>

//Looking to include text and buttons on the first image. Here's the code:

<div class="container">
  <div class="row justify-content-center">
    <div class="col-lg-8" alt="Clean Haven Products, Clean Haven Multipurpose Soap, Affordable Soap manufacturers in Nairobi">

<div class="hero-wrapper text-center mb-4">
  <h1 class="hero-title text-white mb-4">Creating Products and Building Solutions is what
 <span class="text-primary">we do.</span>
  </h1>
    <p class="text-white-50">We would love to tell you more about us or get in touch.</p>

        <div class="mt-4">
          <a href="contact.html" class="btn btn-primary mt-2 mr-2" alt="clean haven soap">Contact Us</a>
          <a href="about.html" class="btn btn-success mt-2 mr-2">Learn More</a>
        </div>
      </div>
    </div>
  </div>
</div>

//Providing the CSS for my image slider below as requested by Evik:-

  div#captioned-gallery {
    width: 100%;
    overflow: hidden;
    border: 0;
    padding: 0;
    margin: 0;
  }
 
  figure.slider {
    position: relative;
    width: 500%;
    height: 100%;
    padding-top: 0%;
    font-size: 0;
    animation: 30s slidy infinite; 
  }
  figure.slider figure { 
    width: 20%;
    height: 100%;
    display: inline-block;
    position: relative; 
  }

  figure.slider img {
    width: 100%;
    height: 100%;
}

//That's the end of the css for the image slider

Answer №1

Presenting to you something I've created. Hope it aligns with your expectations.

I've incorporated a div with the class content and set its position as absolute. Feel free to adjust its positioning as needed. In my setup, I've positioned it 25% from the top and horizontally centered.

UPDATE: Made enhancements using media queries. At this stage, I've only altered the color for various screen sizes. However, you have the flexibility to make changes related to position, size, etc., by utilizing media queries.

.content {
    position: absolute;
    left: 0;
    right: 0;
    top: 25%;
    transform: translate(0,-50%);
    margin-left: auto;
    margin-right: auto;
    text-align: center;
    font-size: 36px;
  }
  
  div#captioned-gallery {
    width: 100%;
    overflow: hidden;
    border: 0;
    padding: 0;
    margin: 0;
  }
 
  figure.slider {
    position: relative;
    width: 500%;
    height: 100%;
    padding-top: 0%;
    font-size: 0;
    animation: 30s slidy infinite; 
  }
  figure.slider figure { 
    width: 20%;
    height: 100%;
    display: inline-block;
    position: relative; 
  }

  figure.slider img {
    width: 100%;
    height: 100%;
}
@media screen and (min-width: 1024px) {
.content {
color: green;
background-color: cyan;
}
}
@media screen and (min-width: 768px) and (max-width: 1023px) {
.content {
color: red;
background-color: lightgreen;
}
}
@media screen and (max-width: 767px) {
.content {
color: blue;
background-color: yellow;
}
}
<div id="captioned-gallery">
    <figure class="slider">
      <figure> 
        ≪img src="https://via.placeholder.com/200">
        <div class="content">
        Greetings
        </div>
      </figure>
      <figure>
        <img src="https://via.placeholder.com/200" alt>  
      </figure>
      <figure>
        <img src="https://via.placeholder.com/200" alt>       
      </figure>
      <figure>
        <img src="https://via.placeholder.com/200" alt> 
      </figure>
      <figure>
        <img src="https://via.placeholder.com/200" alt> 
      </figure>
   </figure>
 </div>

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

How can I fix the issue with Parallax scrolling not functioning properly? (Using Next.js Image + Tailwind)

What am I missing to get parallax scrolling to work? <div className="h-screen"> <div className="relative h-full w-full bg-cover bg-fixed bg-center bg-no-repeat"> <Image src="https://images.unsplash.com/photo-1454496522488-7a8e488e86 ...

How can you conceal an HTML element when the user is using an iOS device?

I need the code to determine if a user is using an iOS device and, if not, hide the HTML input type "Play" button. So, I'm uncertain whether my iOS detection is correct, the hiding of the "Play" button in the code, or both: <!DOCTYPE html> < ...

Alignment of Inline SVG in HTML

I am struggling to align an inline SVG within a bounding DIV correctly, as shown in this example. <!DOCTYPE html> <html> <body> <div style="border: 1px solid black; height: 50px; width: 100px; vertical-align:top;"> < ...

I'm curious about why I'm receiving the error "Unable to bind to 'ngFor' since it is not recognized as a property of 'li'. Can someone please explain why this is happening?

The issue is related to the *ngFor directive for nonvegfoodlist app.component.ts import { Component } from '@angular/core'; export class Menu { id : number; name :string; } const veg : Menu[] = [ { id:1 , name:'Rice'}, { id: ...

Numerous HTML documents being uploaded to the server for a multitude of individuals

Currently, I am developing a game on a website where players create new rooms and are assigned specific roles with individual powers. Some players need to wait for input from others, creating a dynamic gameplay experience. Additionally, there are certain ...

Attempting to align a banner image in the middle using CSS styling

I'm having some trouble getting the banner image to be centered on all screen sizes. It looks good on smaller screens, but on larger ones it seems to be shifting to the left. Here's what I've attempted so far: .banner { padding-top: ...

Can CSS be used to automatically focus on a div element?

Can CSS be used to set autofocus on a div element? <div class="form-group" style="margin-left:10px"> <label for="organizationContainer" class="nmc-label">@Res.GroupStrings.CreateNewGroupOrganization</label> <div id="organiza ...

When typing in the textarea, pressing the return key to create a line break does not function as expected

Whenever I hit the return key to create a new line in my post, it seems to automatically ignore it. For example, if I type 'a' press 'return' and then 'b', it displays 'ab' instead of 'a b'. How can I fi ...

What is the correct way to properly insert a display none attribute

I'm experiencing some alignment issues with the images in my slideshow. I used this example as a reference to create my slide: https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_slideshow_dots When clicking on the next image, it seems to mo ...

How to reference a ListView control using its DataSource in a C# class

Currently, I have a ListView embedded in a webpage connected to a C# class datasource called CommentsDAO. This class contains the necessary methods to retrieve or delete data from the ListView. While data retrieval is successful, deleting a row proves to b ...

The functionality to open the menu by clicking is experiencing issues

I'm attempting to replicate the Apple website layout. HTML structure: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" conte ...

PHP loaded HTML does not allow JavaScript to execute

My system includes an announcements feature where all announcements are retrieved from a database and displayed on the screen using Ajax and PHP. Below is the code snippet used to load each announcement onto the page: echo '<div id="announcements ...

Adding HTML elements dynamically using jQuery: A how-to guide

My objective is to start with one element upon loading the page, and this element should have an ID of "something_O". When the user clicks on an add link, a new identical HTML element should be added underneath the existing element. The new element should ...

A miniature triangle-shaped bubble crafted with 1px of CSS3 styling

Currently, I am experimenting with CSS3 and creating bubble shapes. However, I have encountered an issue. I am trying to create a triangle with a 1px border, but the result is a thicker triangle than desired. You can view my code on this fiddle : FIDDLE ...

How can I prevent the same JavaScript from loading twice in PHP, JavaScript, and HTML when using `<script>'?

Is there a PHP equivalent of require_once or include_once for JavaScript within the <script> tag? While I understand that <script> is part of HTML, I'm curious if such functionality exists in either PHP or HTML. I am looking to avoid load ...

Using an image as an onclick trigger for a JavaScript function

I am working on a registration page as part of my university project where users can create an account and store their information in a MySQL database. One feature I'm implementing is the ability for users to select an avatar picture. Below is the co ...

Incorporate new content into JavaScript using the input element

I have a unique question - can text be added to JavaScript using the input tag? For example, <input type="text" id="example" /> And let's assume the JavaScript function is: function display_text() { alert("The text entered in #example wi ...

Choose CSS Option

I need assistance with customizing my dropdown select option - see the example below <select> <option value="volvo" title="NEED THIS BIGGER AND FORMATED" >Volvo</option> <option value="saab">Saab</option> <option val ...

Can one customize the background color of a segment in a radar chart using Chart.js?

Could I customize the color of the sectors in my radar chart to resemble this specific image? https://i.stack.imgur.com/U8RAb.png Is it feasible to achieve this using Chart.js? Alternatively, are there other chart libraries that have this capability? It ...

Unique content on a web page when it is loaded with HTML

Is there a way to dynamically load various content (such as <img> and <a>) into divs every time a page is loaded? I've seen websites with dynamic or rotating banners that display different content either at set intervals or when the page ...