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

More content will not be displayed beneath folded DIVs arranged to stack on mobile devices

On my website, I have two separate sections dedicated to use cases and benefits. Here is the code: .onboardmessaging { min-width: 100%; } .onboardmessagingwrap { min-width: 100%; } .usecase { padding-left: 8vw; max-widt ...

Enhance your website with a stylish CSS jQuery menu that lets you toggle, slide

If you're curious about the code, take a look here! Here are some of the issues I'm facing: The div doesn't toggle to hide when clicked on itself, only when another one is clicked. (UPDATE: it actually won't toggle at all) When t ...

Is there a way to adjust the input type date format to show mm/dd/yy?

My input type is set to "date" with the default format of mm/dd/yyyy. However, I would like to change it to mm/dd/yy. Is there a way to adjust the format of a date input? Date: <input type="date" id="date" name="date" value="mm/dd/yy" required/> ...

The navigation bar vanishes from sight while scrolling underneath other sections

UPDATE: Problem solved! I discovered that the 'overflow:hidden' inside the #main for the media query was causing the navigation to disappear. I have a scroll navigation positioned at the top of my webpage. However, as I scroll down, the navigati ...

Dropzone: Sending files after an AJAX request is completed

I'm in the process of developing a CRM php tool, which is functioning well at the moment. However, I need to enhance it with an upload file system feature. After some research, I came across Dropzone.js, which seems to be exactly what I need. The chal ...

What is the best way to position the section and footer to the left side of the sidenav?

I am relatively new to the world of html and css, trying my hand at constructing html layouts. I have encountered a bit of trouble in aligning the footer and section to the left of the nav bar. No matter what percentage widths I use, they always end up ove ...

Tips for implementing a CSS Flexbox layout with varying div heights

I am working on a page that features five unique panels, each with its own distinct height and width. I have been considering implementing CSS Flexbox to ensure these panels stack properly as the page becomes responsive. However, one major issue I've ...

I possess an array with a specific structure that I wish to substitute the keys as demonstrated below

The data array is currently structured in this way. I have attempted various methods but have not been able to find a suitable solution. I need to send the JSON below via an AJAX request, however, I do not want the keys 0 and 1 in both child arrays. [sch ...

The float right attribute doesn't stay contained within the box; instead, it drifts outside the box

I've been struggling to keep this box fixed at the top of the browser, but I'm facing an issue with the positioning on the right side. I can't seem to figure out how to solve it, so I'm reaching out for some help. #StickyBar #RightSide ...

Using the flexslider to override CSS styles in an <li> element

I have implemented the flexslider by whoothemes on my responsive website to showcase tiles. However, I am facing an issue with setting a specific width for the tiles on various devices. Upon inspecting with Chrome, I see this code: <li style="width: 21 ...

Use JavaScript to generate an HTML element that has an attribute mirroring its text content

Trying to figure out how to create an HTML element similar to this: <option value="Replaced">by this</option> For example: <option value="ThisIsTest">ThisIsTest</option> UPDATE Using jQuery, I need to achieve something like thi ...

Delete particular user inputs following a $.ajax request

I have created a search feature with inputs that allow users to search the database using ajax requests. Unfortunately, I am facing an issue where the response from the server includes the search inputs themselves. This is not what I want. Here's a ...

Unable to get CSS to function properly on website

I am having trouble getting my text to format properly on my web page. I have defined rules in my style sheet to center an object on the screen, but it's not working as expected. Here is the code for my web page: body { text-align: center; } h1 { ...

jquery causing issues with content loading

Greetings everyone, I have been attempting to load content into a div using this tutorial with the help of jQuery. However, I am encountering an issue where when I click on the link <a href="about.html" class="panel">Profile</a> , it loads ...

Performing recursive XML parsing with the power of JQuery

<script> $(document).ready(function(){ const xmlData = "<root> \ <method name='A'> \ <childcall name='B'></childcall> \ ...

In React Typescript, the input type="checkbox" does not show any value in the value attribute

I'm facing an issue with displaying text next to a checkbox in React Typescript. When I try to use the value attribute, it doesn't seem to work as expected. Also, attempting to set innerHTML throws an error stating that input is a void element ta ...

Exciting transition effect for font sizes in CSS

Issue: Hover over the X and wait for the div to collapse completely. Move away from the X Notice how the div jumps to the bottom and then back up. Inquiry: How can I prevent text wrapping while expanding the div during animation? (Currently using del ...

Is there a way to extract just the JSON data from res?

While creating a search functionality to display a list of users, I encountered an error when attempting to load additional pages to show more users: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data var result = JSON.pars ...

Enable the toggle effect in jQuery to smoothly animate the button downward when clicked

Have you ever wondered about the magical movement of a button when it is clicked? Instead of staying in place, the button gracefully glides down and returns to its original position. To see this enchanting effect in action, check out the HTML, CSS, and jQu ...

What methods are available to modify, append, or remove an attribute from a tag?

I have an HTML document that contains two different types of 'tr' tags. <tr bgcolor="lightgrey"> <tr> Each 'tr' tag includes 3-4 lines of code with embedded 'tags' within them. However, when I try to access the a ...