Issue with position: fixed in IE9

If you visit this website and scroll down the page, you will see that the right panel with shopping and categories moves along with you...

The script I am using for this functionality is:

 $(function () {
    var btn = $('.scroll');
    var btnPosTop = btn.offset().top;
    var win = $(window);
    win.scroll(function (e) {
        var scrollTop = win.scrollTop();
        if (scrollTop >= btnPosTop) {
            btn.css({ position: 'fixed', top: 10, marginTop: 0, 'z-index': 1, width: '260px'});
        } else if (btn.css('position') === 'fixed') {
            btn.css({ position: '', top: '', marginTop: '0px', 'z-index': 0 });
        }
    });
});

Everything works well except for one issue - in IE 9, the div disappears while scrolling down (it's still there but not visible).

I have tried using z-index in the script above to solve the problem, but it hasn't helped.

Do any of you have a suggestion for a solution?

Answer №1

To solve the issue, include a position : relative declaration in your CSS for the element with id #sidebar.

The z-index property will only take effect if the position of the element is not set to static.

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

Retrieve information from an ajax response in XML format

AJAX Call Code Example $.ajax({ url: '/services/LTLGadgetV2.aspx', type: 'Get', success: function (result) { console.log( result); } }); The response in the console: Sample XML <RateResults xmlns ...

Row Carousel Share - Horizontal Perspective

Having some trouble getting my carousel to align horizontally with other text in a row – it keeps taking up the full width instead of the 40% I've set. Below, you'll find the code snippet and screenshots for reference. In the screenshot above ...

Utilizing jQuery and PHP to Refine Database Search Results

I am a novice currently embarking on my journey to create my first website, integrated with a database system which is also new territory for me. Struggling to decide between jQuery and PHP for a specific task related to data handling, I seek guidance from ...

Can text be formatted differently based on its length and whether it wraps onto multiple lines?

Looking to display book titles on a webpage with varying lengths. Some are short enough to fit in one line, while others are longer and wrap onto two lines. Is it possible to apply different styles (such as color or line-height) for these two cases using ...

The Ajax call in Wordpress triggered twice, and despite searching for other solutions, I couldn't find a resolution

Hi there, I've been trying various things but haven't found a solution yet. I have simplified my approach as much as possible. I am attempting to toggle a 'td' (HTML element) so it can change classes (this is the first step towards achi ...

Having trouble with Cordova and JQuery AJAX integration?

After researching for a couple of hours, I discovered that my cordova app (CLI 5.3.3) is displaying a "page not found" error when making AJAX calls through jQuery. Despite following all the steps in the whitelist plugin (https://github.com/apache/cordova- ...

Display and conceal the information with a hyperlink

I need to create a content DIV that includes a link to expand and collapse it. Within this content DIV, there is an unordered list. Initially, only two list items should be displayed with an expand link. If users want to see additional list items, they mu ...

What are some ways to create an opaque effect for a DIV element

I've set up a div on the top of my website that spans 100% width and is in an absolute and fixed position. The code for it looks like this: div.header{ height: 60px; width: 100%; position: absolute; position: fixed; top: 0px; ...

"Utilizing a full-width jumbotron to enhance the browser's

I've been attempting to create a jumbotron bootstrap element that spans the full width of the page. I've tried using both col-xs-12 and the w-100 classes, but it doesn't seem to have any effect. Could someone provide guidance on how to adju ...

The navigation bar and text subtly shift when displayed on various devices or when the window size is adjusted

Hello, I am brand new to web development and have encountered an issue on my website. Whenever the window is resized or viewed on a different screen, the navigation bar (which consists of rectangles and triangles) and text elements start moving around and ...

Intermittent rendering problems in Chrome due to CSS printing with a fixed header and footer

I am attempting to customize the format of an e-commerce receipt for printing, including a fixed header and footer that will appear on every printed page. However, I am encountering intermittent issues. Sometimes, the layout works correctly, while other ti ...

Issues may arise when attempting to parse AJAX responses using Javascript/JQuery AJAX

There are many posts on this topic, but I am having trouble finding the specific information I need. Here is where I am struggling: I have an AJAX request for an ID and an integer (which will be used as a margin to apply on the DOM later). This is the re ...

Center an image vertically and horizontally within a div element inside a container, even if the image sizes and aspect ratio differ, while also including padding

I am looking to vertically align images with varying ratios, where the image may be larger or smaller than the content and also include padding; I have tried different solutions found here, but none seem to cover all my requirements; I specifically need i ...

Tips for effectively utilizing the mock-ajax library in conjunction with Jasmine

Currently, I have a function that requests JSON data and then modifies the DOM in the success function. To simplify my Jasmine tests, I am attempting to utilize the mock-ajax library instead of exposing private functions for mocking. Despite setting reque ...

Reduce the number of columns in JQGrid when the window is resized

I've encountered an issue with jqGrid while working on a table with numerous columns. When resizing the browser window or viewing the web app on a mobile device, I need to display only a limited number of columns in the grid table for better usability ...

Angular - Implementing Opacity Inheritance for Child Components

Is there a way to prevent Angular Child components from inheriting their parent's styles, specifically opacity? I have a form wrapper positioned on top of the page as shown below: import {Component, EventEmitter, Output} from "@angular/core" ...

Changing boolean values to integers

I am trying to save values in a MySql field of type tinyint(1) that have already been converted from boolean using php's intval(). For example: $data = true; $foo = intval($data); if (is_numeric($foo)){ print_r($foo); } The i ...

Show where the image should be placed according to the coordinates of the mouse click

My project begins with a blank canvas, prompting the user to click anywhere on the page to reveal an image. My goal is to show an image at the exact location where the user clicks. Although I can successfully trigger an image to appear in the corner of the ...

Two neighboring sections containing dynamic elements. One section automatically adjusts its size to fit the content, while the other allows

I need to display 2 adjacent boxes with dynamic content rendered using Angular. The Container should have the same height as Box1. The height of Box2 may vary due to its dynamic nature, but it should never be taller than Box1. If it does become higher, a s ...

Creating a dynamic 2D image using HTML5 animation

As a beginner HTML5 developer, I have been exploring ways to create an animated image using multiple jpg files stored in a specific folder on my website. My goal is to design an animation of a rabbit running across the page when a user clicks on a button. ...