The issue with the jQuery sliding background issue

Looking for a way to incorporate slide in/out descriptions to images using jQuery like the method outlined here. Upon implementation on my website, the text within the <p> tag slides in as expected, but an issue arises where the background of the text appears below the image. Despite adjusting the z-order to no avail, I have yet to pinpoint a simple example demonstrating this problem. Perhaps it's a common stumbling block...

$(document).ready(function() {

    $(".product-image").fadeIn("slow");  

    $(function(){  
        $('.productInfo').showFeatureText();    
    })

$.fn.showFeatureText = function() {
    return this.each(function(){    
    var box = $(this);
    var text = $('p',this);            

    box.hover(
        function(){
            text.slideDown("fast");
            text.css('z-index', '1000');    
        },
        function(){
            text.slideUp("fast");
        }
    );

  });
}

}); 

.product {
    float: left;
    margin: 10px 12px;
    width: 215px;
}

    .product .productInfo {
        height: 250px;
        overflow: hidden;        

    }

        .product h3 {
            font-size: 1.75em;
            font-weight: normal;
            margin: 0 0 0px 0;
            padding: 0;
        }

        .product-image {
            background-color: #edece8;
            border: 1px #e6e3d8 solid;
            height: 200px;
            margin: 0 0 0px 0;
            padding: 6px;
            width: 200px;
            display:none;

        }

        .product p {
            margin: -75px 6px 6px 6px;
            display:none;
            background: #000000; url(/Images/feature_bg.png) repeat;
            overflow: hidden;
            height:65px;
            width:200px;
            z-index:1;
            overflow:hidden;
        } 

Answer №1

When using the z-index property, it is important to remember that it must be accompanied by a position value. To ensure proper layering of elements, consider setting position:relative on the image and its containers, as well as on the paragraph element (p) and its containers. Additionally, make sure to define the appropriate z-index values for each of these elements.

Answer №2

Hey Adam, I've created a sample that should be useful for you. I trust this will assist you.

Check out the example here

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

Transfering data to Handlebars while rendering a template

Is there a method to pass a variable to a handlebars template during its rendering process? Below is the template in question: <script id="listingTopics" type="text/x-handlebars-template"> {{#each this}} <div class="wrapper_individual_listing ...

Best practices for making an AJAX call to fetch information from a database

I have a database containing a single table. The table includes columns for Company and Time, among others, with Company and Time being crucial. Users can make appointments by filling out a form. Within the form, there are 2 <select> elements - one ...

What is preventing me from adjusting the padding of the mat-button?

Trying to adjust the default padding of a mat-button, but encountering issues with changing the component's style. Any suggestions on how to subscribe to the default padding (16px)? I've attempted modifying CSS properties to set the padding of a ...

Troubleshooting: Why is jQuery .data function not functioning

After setting up a page that allows a user to click on an anchor and dynamically display new content in a specified div using jQuery .html, I encountered an issue. Despite attempting to pull content from custom data attributes, the functionality isn't ...

Click to slide the div down and up when needed

Currently, I am utilizing the code below to implement a slide up/down effect on a div using JavaScript. The slide down action is triggered by a button, while the slide up action is associated with a close text. My goal is to have the button toggle betwee ...

Utilizing CSS to adjust the position of a background image at its starting point

I'm looking to create a unique design for the sidebar on my Tumblr page, where the header has a curved shape while the rest of the sidebar has a squared-off look with 100% height. This design should flow seamlessly off the page without a visible foote ...

Is it possible to display multiple qTips for the same target using jQuery qTip2?

I am currently utilizing the jquery qtip2 plugin to generate a mouseover tooltip. Here is the code snippet I am using: $(document).ready(function() { $("#optionalProdsImgPreview_1").qtip({ content: "<img src='http://mysite.com/myimg.jpg&ap ...

Additional blank space beside a webpage

@font-face { font-family: 'Open Sans'; font-style: normal; font-weight: 300; src: local('Open Sans Light'), local('OpenSans-Light'), url(https://fonts.gstatic.com/s/opensans/v13/DXI1ORHCpsQm3Vp6mXoaTRampu5_7CjHW5spxoeN ...

Do I really need to include the jqueryui css file in order to enable autocomplete

Bootstrap is my go-to for CSS, but I only use jQueryUI for autocomplete. Do I really need the jQueryUI CSS or can I just use the functional parts? ...

Varied results may occur across various browsers despite the use of reset.css

What causes different browsers to display the same website differently due to inline style? Below is a snippet of CSS code: .label-input, .label-input label, .label-input input , .label-input select , .label-input span { float: left; display: inline; mar ...

Is it possible to track the y-position within sections while using scrollOverflow scrolling in Fullpage.js by utilizing iscroll-probe?

I'm currently utilizing the most recent version of fullpage.js with the scrollOverflow feature enabled. You can see an example here: Fullpage.js actually utilizes iscroll.js for this functionality, and I have integrated the "probe" version of iscroll ...

How to Submit a Form Using Jquery and UTF-8-Encoding

Can anyone help me with a form submission issue? Below is the code I am using: <script type="text/javascript" src="js/jquery-1.7.2.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#form").sub ...

Achieving consistent radiobutton width across various column widths

Struggling to match the size of the radio button area (input-group-addon) in col-sm-4 and col-sm-6 columns? Considering using min-width to achieve a consistent width but finding no success? Seeking uniform width for radio button controls? Check out this vi ...

Unable to match the data and retrieve the value for $passwd

*issue:* I am facing a problem in retrieving data from the model which is causing me to be unable to match the old database data with the new one. As a result, I am not able to receive any success message or display any error. Can anyone assist me with thi ...

Using jquery to navigate back to the search results page

I am trying to figure out how to use jquery to return to the search results page, but my current code always takes me back to the main data instead of the search results. Can anyone help me with this issue? $(document).ready(function() { $("#kembali ...

function to post data using jQuery

I have been executing the following code snippet: $.post('https://graph.facebook.com/me',{}, function(msg){ console.log( "Data Saved: " + msg ); } ); However, when checking the output in Firebug I only see Data Saved :, nothing el ...

Turning off a hyperlink with jQuery

Is there a way to effectively disable a link in jQuery without changing the anchor's href attribute? I initially tried setting disabled to true, but it seems that approach isn't working as expected. The goal is to prevent the user from being redi ...

Chartist JS: line graph dipping beneath the X-axis

I am currently using the Chartist JS jQuery plugin and encountering an issue where one of the functions is extending below the x-axis even though it does not have any negative points. Is there a way to resolve this issue? Please refer to the image for bet ...

Having a go at changing the background color of odd and even <li> elements, but encountering a JavaScript issue where only the

My goal is to have alternating background colors for odd and even list items in my unordered list. The color alternation was working fine until I added JavaScript inside each list item. When I remove the JavaScript, the background colors alternate correctl ...

Using Various Buttons in a Bootstrap Form

I have implemented Bootstrap to create a form. The form structure is as follows: <form action="default_results.php" method="post" class="calculator" name="frmCalculator"> At the beginning of my code, I used the above form code. At the end of the pa ...