Negative top margin in IE9 causes an element to become stuck when a floated and cleared child element is present

I have encountered an unusual issue in IE9 and I have spent a significant amount of time trying to track it down and replicate it.

Here is the code snippet that we are working with:

<div class="container">
    <div class="movable">
        <div class="stuff">Stuff</div>
        <div class="stuff special">Stuff Special</div>
        <div class="stuff">Stuff</div>
        <div class="stuff">Stuff</div>
    </div>
</div>

This code produces the following layout:

We are trying to move the yellow box above (outside of the container) and ensure that the .stuff elements clear properly. We want to float at least one .stuff element, specifically .special, so we implemented the following CSS:

.movable { margin-top: -70px; }
.stuff { clear: both; }
.special { float: left; }

On the left side are the results seen in Chrome and Firefox, while on the right side are those from IE9:

As you can observe, IE9 seems to be having difficulty applying the negative margin-top, and it consistently gets stuck on the element that has both right or left float and clear: both; applied to it concurrently. This unique combination of properties triggers this erratic behavior.

Here is a jsFiddle demonstrating the issue, which you can experiment with

This issue has arisen within a rather large application, and due to certain constraints, using top instead of margin-top would disrupt other functionalities.

Does anyone have any suggestions on how to address this problem in order to correctly display it in IE9?

Answer №1

To resolve the issue with the .movable element, one possible solution is to clear it. This can be done by either adding a clearfix class or applying overflow:hidden directly to it. Another option could be floating the element, but this may not be suitable for your specific webpage layout.

.movable { margin-top: -70px; overflow:hidden; }

Check out the code on jsFiddle

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

Trouble with ASP.NET Master Page CSS Rendering Incorrectly

My CSS seems to be causing some trouble as the DIVs are not aligning as they should. Instead, they are just wrapping around the text and not adjusting the page layout properly. Here is an example of my CSS: body { height: 95%; width: 100%; ma ...

Utilizing Bootstrap, the layout structure consists of 4 columns for desktop, 3 columns for small laptops, 2 columns for tablets, and

I need assistance with setting up responsive columns in my HTML code using Bootstrap. Specifically, I want 4 columns per row on desktop, 3 columns per row on tablet, and 2 columns per row on mobile devices. Despite searching on Stack Overflow, I couldn&apo ...

Is it possible to retrieve the value from the searchbar on the server?

I'm seeking assistance on how to retrieve the user-entered value from a search form on my HTML page in my server.js file. I understand that the name/value pair will be cityCode=something, but I'm unsure of the next steps. HTML: <form c ...

Creating multiple lines with kineticjs in a HTML5 environment can be a

Referencing the following page: KineticJS - Drawing Lines with Mouse KineticJs is effective in creating lines, shapes, and enabling drag-and-drop functionality. The provided example consistently redraws the same line, prompting the question of how to draw ...

Is there a way to adjust the height of one div based on the height of another div in Bootstrap?

I am experimenting with a Bootstrap example featuring a table in the left column and 4 columns in 2 rows in the right column. Check out the code below: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css ...

Getting the list items separated from the unordered list in Selenium

My current task involves navigating a list and selecting the correct text entry. The list contains only 2 items: <ul> <li><span>first</span></li> <li><span>second</span></li> </ul> However, ...

How can one effectively pass arguments to jQuery in order to set the tooltip text for Bootstrap from an element within the HTML body

I'm working with a simple markup that triggers a colorful bootstrap tooltip when hovering over a button in the body. Currently, the tooltip text is hardcoded into the jQuery function. I want to find a way to pass the tooltip text to the jQuery functio ...

What steps should I take to ensure that this accordion is responsive?

I am currently working on an accordion design and trying to figure out how to make it full width and responsive. I have experimented with various width and display attributes, but I haven't been able to achieve the desired result yet. If you'd l ...

Show a collection of elements containing attributes in JSX

I have a React component where I am displaying data from an array called pkgData: <div className="mainApp"> <div className="pkgsList"> {pkgData.map((p) => <h3 key={p.name}>{p.name}</h3> ...

Tips for choosing elements in jQuery that do not contain a particular element

How can I target elements in jQuery that do not contain a specific element within them? I am trying to create a sidebar that will close when the user clicks either the menu or the sidebar itself, excluding dropdown menus. Below is the structure of the menu ...

Ways to align a bootstrap 4 row both vertically and horizontally in the center amidst other rows

Assume there is a main menu followed by three rows. The first row should be at the top and the third at the bottom, while the second row needs to be centered both vertically and horizontally. As you scroll down, the main menu should be able to hide while ...

Loading hover images in css through jQuery preloading

Is there a reliable method for preloading CSS hover images using jQuery that anyone knows of? My ideal scenario would involve adding a class (for example, "pre-load-hover") to any element needing preloading, and then implementing JavaScript in $(document) ...

"Learn the process of integrating a delete button into your PHP form for the purpose of removing rows from your MYSQL database

Hello, I am embarking on my journey with PHP coding and encountering some challenges. Specifically, I am trying to incorporate a delete button for each row in my code, but unfortunately, it doesn't seem to be functioning as expected. Below is the sn ...

The issue with jspdf is that it is failing to generate PDF documents of

I'm currently developing a resume builder app using ReactJS. One of the functionalities I'm working on is enabling users to download their resumes as PDFs. However, I've encountered an issue with the generated PDFs when using jsPDF. The down ...

Material-inspired Design Device Compatible DIV slide with JS, JQuery, and CSS

My goal is to achieve something similar to this: Desired Live Website I am looking for a feature where clicking on the div will slide in content from the right, load an external page inside it, and close when prompted. The slider div should be device c ...

(no longer supported) We are unsure about the usage of /deep/, >>>, and ::ng-deep, ::v-deep

Since /deep/ has been deprecated, I have found that using global styles instead is the only viable solution. Does anyone know of an alternative solution where we can still maintain encapsulation or scoped styling? ...

What's the best way to make sure an image in CSS respects the height of its parent flexbox section?

This question addresses a clear problem: Flexbox - Img height conflict. However, the accepted answer does not meet my specific needs. One potential solution involves using absolute and relative positioning. While this resolves sizing issues, it interferes ...

Showcasing pictures with a prominent large image accompanied by two smaller ones on the right side

In my use of Material-ui-next, I am attempting to create images in a specific layout. ------ --------- | | | | 2 | | | | 1 |---| | | | | 3 | ------ --------- I have encountered some unusual issues. 1 - 3 appears below 1 ...

Steps for designing a stationary footer in HTML and CSS

I have implemented a static footer on my website: HTML <div class="card fixedFooter"> <div class="card-body space-around"> <button type="button" class="buttonFooter" routerLink="/myRouter" > <i class ...

I'm encountering an issue with the dropify plugin where the data-allowed-file-

While using the dropify library to style file upload elements in my form, I ran into an issue with the data-allowed-file-extensions parameter not working as expected. Despite specifying allowed file extensions like "png jpg jpeg", the validation for input ...