Background covers image in slider with border

Let me explain using a visual representation:

The background of the first div is grey and white, where white represents transparency. The border of the image slider is yellow, while my images in the slider are red. I want it to look like this:

However, currently it looks like this:

Although this is just a representation, I believe it conveys what I am trying to achieve.

Here is the code snippet:

<div class='slider'>
      <div class='top_area'>
        <div class='top_area_shadow'>
          <div class='contact'>
          </div>
        </div>
      </div>
      <div id='slideshow'>
        <div id='slidesContainer'>
          <!-- <span class="control" id="leftControl"></span> -->
          <div class="slide">
            <img src="../images/daf.png">
          </div>
          <div class="slide">
            <img src="../images/daf.png">
          </div>
          <div class="slide">
            3
          </div>
          <!-- <span class="control" id="rightControl"></span>          -->        
        </div>        
      </div>
    </div>

And here is the CSS:

.top_area{
  height: 80px;
}

.top_area_shadow{
  height: 80px;
  background: url(../images/header_shadow.png);
  background-position: center;
}

.contact{
  position: absolute;
  background: none;
  height: 32px;
  margin-left: -510px;
  margin-top: 32px;
  width: 1020px;
  left: 50%;
  text-align: center;
  display: inline-block;
}

...

You can download the images from this link:

https://dl.dropboxusercontent.com/u/59666091/img.zip

In summary, I am struggling to create a slider where the image appears under a transparent border image (yellow in the representation). It works without a grey background, but not with one. What could I be doing wrong?

I have tried using z-index, but that didn't solve the issue...

If anything is unclear, please let me know in the comments. Thank you )

For a full demo and to experiment further, visit dl.dropboxusercontent.com/u/59666091/csshtml.zip

Answer №1

This is the solution that worked when I tested it on your full sample:

Simply remove the background-image property from the #slidesContainer and insert the image directly into the HTML using the <img> tag:

HTML:

 <div id="slideshow">
    <div id="slidesContainer">
       <img src="images/border.png"> <!-- removed from css -->
       <!-- <span class="control" id="leftControl"></span> -->
       <div class="slide">
         <img src="images/daf.png">
       </div>
       <div class="slide">
         <img src="images/daf.png">
       </div>
       <div class="slide">
         <img src="images/daf.png">
       </div>
       <!-- <span class="control" id="rightControl"></span> -->        
    </div>       
 </div>

CSS:

 .slider{
  background: url(images/slider_bg.png);
  background-position: bottom;
  width:100%;
  height:330px;
}

#slidesContainer {
  width:1020px;
  height:244px;
  overflow:hidden;
  left: 50%;
  margin: 0px 0 0 -510px;
  position:absolute;
  background-color: #fff;
}

#slidesContainer > img{
  left: 50%;
  margin: 0px 0 0 -510px;
  position:absolute;
  z-index: 1;
}

#slideshow #slidesContainer .slide {
  margin:0 auto;
  width:1020px; 
  height:244px;
  position: absolute;
}

Answer №2

give this a shot

#gallery .image img {
  z-index: 9999;
}

in case that doesn't do the trick, delete the previous code and attempt

#gallery #imagesContainer .image img {
   z-index: 9999;
}

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

Shuffle the elements within each container in the DOM

Currently, I am focusing on designing a card-based layout where each card contains details about the product. One important detail is the phone number, which is displayed in the format 555-555-5555. My current goal is to clear the text value of the phone ...

Using Jquery to automatically populate an input field if the user already exists

I'm currently working on populating a form if the user input for name and firstname already exists in my database. However, I am facing an issue with my JavaScript program where it fails to check if the name and firstname combination already exists i ...

Exploring the Power of Websharper with Sitelets and Forms

I have been working on developing a form using Websharper to gather user input. Currently, I have identified three actions for my website: type MyAction = | [<CompiledName "">] Index | [<Method "POST">] GetUser of username : string ...

Maximizing performance: optimizing Javascript usage in .net Web Application

After completing a web application using C#, ASP, and some javascript, my main page is cluttered with a mix of javascript/jQuery at the bottom. I have several ajax calls to web methods in this mess. Is there a way to organize this javascript into multipl ...

Retrieving PHP output from multiple arrays using AJAX

I'm new to AJAX and I'm struggling to retrieve arrays. My goal is to update a notification bar in real time using AJAX. I've managed to update the count displayed on the balloon, but I can't figure out how to also fetch messages from My ...

Immersive Bootstrap Header Design

I've been attempting to achieve a full-screen background within the header element, but for some reason it's not displaying properly? Code header { position: relative; width: 100%; min-height: auto; text-align: center; color: #fff; ...

function embedded in velocity.js chain

How can I effectively execute this code? I keep encountering various errors. After the sequence is completed, I want to incorporate an additional function. I am utilizing jQuery in conjunction with velocity.js $(".close").click(function(){ var my ...

Sending HTML content to viewChild in Angular 5

I'm struggling to figure out how to pass HTML to a ViewChild in order for it to be added to its own component's HTML. I've been searching for a solution with no luck so far. As a newcomer to Angular, many of the explanations I find online ar ...

The use of .setInterval() and Drupal.attachBehaviors is resulting in my JavaScript file running multiple iterations simultaneously

I am facing an issue while delivering ajax content to a page and needing to reattach Drupal behaviors to that content. My current approach involves using jQuery to poll the server every 5 seconds for data, which is then displayed on the page. Drupal.behav ...

A step-by-step guide on how to use ajax and node to save a file onto

Trying to save a file to the user's disk when they click on it using this ajax code: $('.cv_download').on('click',function(){ var fileName = $(this).text(); console.log(fileName) var temp = {"file" : fileN ...

The length returned by a Javascript object property is not accurate

When I clone an element dynamically using jQuery and then ask an object to return its length, it always returns a value of 1. You can view the issue in this fiddle: https://jsfiddle.net/gatzkerob/x5xd2x7q/3/ <span class="count">0</span> <b ...

What is the best way to extract the value from a text box that is being looped through using the post method in order to insert it into

I was working with the code below. Each textbox for attendance is looped a certain number of times, and I need to capture the value of each attendance when the form is submitted to insert the values into a database. <form method="post" action="insert. ...

"Choose between displaying the Bootstrap Column consistently in a vertical orientation or a horizontal orientation

I'm just diving into the world of HTML/CSS and currently experimenting with Bootstrap Studio for a project. My focus is on creating an 'About' section for a webpage, where I've structured four rows each containing two columns as follows ...

Close button for colorbox modal window containing an iframe

I'm currently utilizing colorbox for a modal popup, and the content of the popup is being sourced from a URL. Since it's displayed within an iFrame, I'm wondering how I can incorporate a close button to the modal popup. Thank you The follo ...

tips on concealing video URL

Is there a way to obscure the URL of a video being displayed on a webpage using the HTML5 Video Player? The video URL is pasted as a <source> element, and I'm unsure how to obfuscate it without causing issues with the player. I'm looking f ...

"Obtaining a JSON response from a server in JSON format through jQuery ajax: A Step-by

I encountered a parse error When using Ajax $.ajax({ type: "POST", url: "getStagingImrReport.do", data: dataString, dataType: "JSON", //if received a re ...

Using jQuery to retrieve the value of an input with a designated class name

Is there a way to retrieve all values from input type text fields with a particular class name? I gave this code a shot, however, it didn't produce the desired result. $('input .classname').each(function(){ console.log($(this).val()); ...

Issue encountered while generating a dynamic listing using Angular

My goal is to generate a dynamic table using Angular. The idea is to create a function where the user inputs the number of rows and columns, and based on those values, a table will be created with the specified rows and columns. However, I am facing an iss ...

What could be causing the jQuery script file to not be detected in the Django admin panel?

While following Django's tutorial, I encountered an issue where jQuery was not loading properly. This caused collapsible fieldsets in the administration panel to malfunction. Despite installing libjs-jquery, the problem persisted. Page not found ...

Styling with CSS: Changing the Background Color of Text

Looking for a solution to apply line-height to text without affecting the background color? Check out the code snippet below and share your ideas if you have any. Thanks! .nb-semnox-impact-grid { display: block; font-size: 6 ...