Eliminate the see-through effect from a logo positioned in a fading container

I created a div with image fading functionality using JavaScript and placed a static SVG logo on top of it. The issue I'm facing is that the logo appears somewhat transparent, allowing the image in the div to show through. Despite adjusting the z-index and opacity of the elements, I haven't been able to achieve the desired look.

Here is the snippet of my code:

<div class="main-slider-container">
 <img src="img/logo.svg" class="img-responsive">
 <div class="slideme" id="slideme"></div>
</div>

CSS:

.main-slider-container{
  position:relative;
   background: blue;

}

#slideme div{
  position:absolute;
  width:100%;
  height:100%;
  top:0px;
  right:0px;
  z-index:0;
  border-bottom: 10px solid #000000;

}

> img {
  position:absolute;
  height:100%;
  top:0px;
  left:0px;
  z-index:1;

}

Answer №1

When you notice there is something visible underneath the logo, I recommend adjusting the background color as well.

> img {
    z-index:2;
    background-color:lightgray;
}

Answer №2

Your SVG logo appears transparent due to its default transparent background.

To change this, simply add a background color.

Updated CSS

img {
  background-color: white;
}

Example with Changes

I have replaced your img src with a functional SVG for better clarity.

.main-slider-container{
  position:relative;
  background: blue;
}

#slideme div{
  position:absolute;
  width:100%;
  height:100%;
  top:0px;
  right:0px;
  z-index:0;
  border-bottom: 10px solid #000000;
}

> img {
  position:absolute;
  height:100%;
  top:0px;
  left:0px;
  z-index:1;
}

img {
  background-color: white;
}
<div class="main-slider-container">
 <img src="http://www.w3.org/html/logo/downloads/HTML5_1Color_Black.svg" class="img-responsive">
 <div class="slideme" id="slideme"></div>
</div>

If you were trying to adjust z-index and opacity but saw no changes, it may be because the CSS selectors #slideme div and > img aren't targeting any of the HTML elements provided.

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

Execute SQL Server stored procedure passing a collection of dates to disable on a jQuery datepicker

I am currently working on a Classic ASP system that includes a jquery datepicker. My goal is to automatically disable certain days by populating an array with these dates. Currently, the functionality only allows for manual disabling of dates using a funct ...

Zoom out the slider when scrolling

Take a look at this link and as you scroll down the page, notice how the image transitions to iPhone. Can anyone provide insight on how this effect is achieved? ...

Ways to align text on the left within a centered format

It seems like there is something missing here. I am struggling to align text to the left in a centered div. Below is an example of my final work: <div class="grid-row"> <img src="http://www.fununlimitedsports.com/wp-content/images/istock ...

Implementing jQuery to enable the selection of multiple options depending on user input

Assume that when the people input value is 1, then the options for values 1 and 2 will be selectable. However, if the people value is greater than 1, then all other options will become selectable. Is it feasible to enable multiple select options based on ...

Verify if an element with a specific index exists within an array

$.each(constructions, function(i,v) { if ($.inArray(v.name, map[ii].buildings) == -1) {//do something} }; In this scenario, the constructions array consists of unique objects with a name attribute. On the other hand, map[ii].buildings is an array contain ...

Add an image to a container

I am facing an issue with my code that fetches photos from a flickr feed using JSON and appends them to a div inside another div. Currently, all the images are being appended into one div, but I want each image to be appended to a separate div. $.getJSON( ...

Is it possible to load HTML content within a Sweet Alert pop-up

Below is the code I am using to call Swal: window.swal({ title: "Checking...", text: "Please wait", imageUrl: "{{ asset('media/photos/loaderspin.gif') }}", showConfirmButton: false, allowOutsideClick: false }); $.ajax({ t ...

Blazor components experience element interaction while utilizing more than one instance of Blazorise.Bootstrap component

I am facing an issue in my Blazor app where a component with a button and bootstrap collapse works fine when used once on a page, but triggers collapse elements in other instances when used multiple times. This seems to be happening because their IDs are s ...

Intersection of content in panel-body using bootstrap tab pills

Can someone help me solve a major issue? I need the content of each tab to overlap as if they are unaware of each other. Currently, my code is saved in this fiddle: https://jsfiddle.net/axq882de/1/. When I click on different tabs, the contents should remai ...

Ways to boost an array index in JavaScript

I recently developed a JavaScript function that involves defining an array and then appending the values of that array to an HTML table. However, I am facing an issue with increasing the array index dynamically. <script src="https://cdnjs.cloudflare. ...

Display a color box popup when a radio button is selected

I need help implementing a functionality where a popup modal opens when a specific radio button is checked. I have tried using colorbox with an anchor, but it doesn't seem to work with radio buttons. Does anyone have any sample code or suggestions? T ...

"Trouble encountered when attempting to add a CSS class to a select option in Firefox version 5

Here is the HTML code I am working with: <select id="WageBenifits_PayType" name="WageBenifits.PayType"> <option class="selectOption" value="" selected="selected">Please Select Value</option> <option value="COM">COM - COMMIS ...

What is the best way to apply the .addClass('active') method to a specific item in a Bootstrap carousel?

I'm looking to create a modal carousel using Bootstrap and incorporating PHP into the mix. Here is the code I currently have for displaying image previews: <?php $directory = "images/*"; $imagenes = glob($directory.'{jpg,JPG,jpeg,JPEG,g ...

Issue with dynamically adjusting flex box width using JavaScript

Currently, I am developing a user interface that heavily relies on flexbox. The layout consists of a content area and a sidebar that can be toggled by adding or removing a specific class. Whenever the sidebar is toggled, the content area needs to be manua ...

When the form is submitted, the text input vanishes and then the page is refreshed using AJAX technology

Can anyone help me troubleshoot why my page is reloading even though I used AJAX, and how to prevent it from clearing my input text after clicking the submit button? I tried using the show method to resolve this issue but it didn't work. <form met ...

Firing jQuery events on multiple listeners

I have created a custom event that I would like to trigger without any connection to selection. For example, I want to execute something similar to running $("*").trigger('customEvent'); However, jQuery documentation advises against using the ...

A tutorial on preventing backbone.js from automatically adding /# when a dialog is closed

Whenever I navigate back on my backbone page, it automatically adds /# to the URL. This results in loading an empty index page from the Rails home view when pressing back again. Disabling turbolinks fixed this issue for me. However, another problem arises ...

Customized content is delivered to every client in real-time through Meteor

I am currently working on creating a multiplayer snake game using three.js and meteor. So far, it allows one player to control one out of the three snakes available. However, there is an issue where players cannot see each other's movements on their s ...

The styling of a CSS class in Internet Explorer may not be applied correctly if there are multiple elements sharing the same class name

For nearly a full week now, I've been plagued by a persistent issue! Here's the situation: I have 6 step tabs - step 1, step 2, and so on. Each tab has a CSS class called "locked" and "active." "Locked" - this style features top: 3em;, causing ...

Populate the div with an image that stretches to the full height

I'm facing an issue with my website's front page design, where a div is divided into two sections using the Twitter Bootstrap grid system. When the second grid (span9) is taller than the first (span3), the image perfectly fills up the span9 area ...