Firefoxe's slideToggle function adds an additional space

Having trouble with the drop-down menu in Firefox. There seems to be a mysterious gap of about 200 px below the list created by slideToggle. When inspected, this area appears completely empty with nothing in it. Chrome displays everything correctly.

You can find the source here.

I've been trying to fix this issue for 2 days now, experimenting with "display" and "margins".

Below is the main code structure:

JQuery CODE

<script type="text/javascript">
$(document).ready(function(){
    $(".plus1").click(function(){
        $(".open1").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});
</script>
<script type="text/javascript">
$(document).ready(function(){
    $(".plus2").click(function(){
        $(".open2").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});
</script>
<script type="text/javascript">
$(document).ready(function(){
    $(".plus3").click(function(){
        $(".open3").slideToggle("slow");
        $(this).toggleClass("active"); return false;
    });
});
</script>

HTML CODE

<html>
<head></head>
<body>
<div id="wrapper">
<div id="container">

<div id="ul_wrap">

<div class="plus1">
    <ul>
    <li>one</li><li>two</li><li>three</li>
    </ul>
    <p class="open1"></p>
    </div>

<div class="plus2">
<ul>
    <li>one</li><li>two</li><li>three</li>
    </ul>
    <p class="open2"></p>
</div>

<div class="plus3">
    <ul>
    <li>one</li><li>two</li><li>three</li>
    </ul>
    <p class="open3"></p>
</div>

    </div>
</div>
<div id="push"></div>
</div>
<div id="footer"></div>
</body>
<html>

CSS

.wrapper {
    min-height: 100%;
    height: auto !important;
    height: 100%; 
    margin: 0 auto -77px; 
    padding:0;
}
.footer, .push {
    height: 77px;
    clear:both;
}
.footer{
    width:100%;
    background: url('../images/bottom_bg.jpg') repeat-x 0 0;
    position:relative;
    margin:auto;
}
.container {
    width:800px;
    min-height:400px;
    margin:auto;
    margin-top:20px;
    margin-bottom:20px;
    padding:30px;
}
#ul_wrap {
    position:relative;
    margin-bottom:-100px;
    clear:both;
}
#ul_wrap ul{
    display:inline-block;
    position:relative;
    left:-20px;
    padding:5px 0px 0px 10px;
    background-color:#FFFFFF;
    border:1px solid #FFFFFF;
    clear:both;
    height:27px;
}
#ul_wrap li{
    font-size:16px;
    text-align:left;
    float:left;
    list-style:none;
}
.one{
    width:40px;
}
.two{
    width:410px;
}

.three{
    width:88px;
}
.open1, .open2, .open3{
    margin:-5px 0 20px 0;
    position:relative;
    font-size:12px;
    display:none;
}

PLEASE NO COMMENTS LIKE I FORGOT TO CLOSE A TAG OR SMTH, i had to rewrite the entire html code to post it here in short version and shorter names because otherwise it would be 4 page code of css html and javascript. Problem is not in debugging errors in unclosed tags or smth. Source was html validated 1000 times.

Answer №1

After experimenting with margins, display properties, floating, and clearing, I was able to successfully put together a functional layout.

  1. The key was ensuring all elements and parent elements containing floating elements were cleared,
  2. I also discovered that slideToggle wasn't working properly with a white background behind .wrap_ul unless the height of the hiding element was specified when it was set to display:block, only working with inline-block.
  3. Using Display:inline-block caused the footer to float on the right, regardless of clear:both being added to both items;
  4. And specifying a height resulted in slideToggle not pushing the other sliding elements down below, but instead overlapping them.

It's interesting that these issues only arose in Firefox, while Chrome did not experience this flaw...
I have shared the final working code after making adjustments, although I'm not certain which property ultimately solved the puzzle -

  • The background behind the expanding slideToggle list,
  • The footer that is correctly pushed down when the list is expanded,
  • A non-floated footer without any extra gaps or spacing between the dropdown list and the footer).

I hope you find this information helpful!

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

Developing a react native library (create-react-native-library) incorporating a distinct react-native version within its designated Example directory

I'm looking to develop a React Native library, but the testing folder (example folder) it contains the latest version of React Native. However, I specifically need version 0.72.6 in the example folder. Is there a command for this? Current command: np ...

Coming back from the setState callback

In my code, I have a scenario where the Parent component is calling a function from the Child component using refs. Within the Child component function, there is a this.setState method with a callback function embedded in it. handleSaveProject = async () ...

When using Google Chrome, the window.open function may encounter issues when opening a CSV file that contains a '#'

window.open(encodeURI('data:text/csv;charset=utf-8,name,color\njohn,#000000')); When running the above line in Chrome, a downloaded csv file is generated with the following content: name,color john, The issue here is that it appears to be ...

Create visually dynamic charts using either JQuery or CSS based on the values stored in Div elements on the webpage

Can a Jquery or CSS chart be constructed using the values in a set of Divs on a page? For example, if my page contains the following: Value One = <div id="q1">21</div> Value Two = <div id="q2">40</div> Can a bar chart be created ...

Mastering the syntax of Babel in Node.js

Hey there! I've encountered a syntax issue while migrating to babel. The problem lies in importing an unnamed module. In traditional Node.js default import, it's possible to import without specifying the module name and passing in the app. Howeve ...

What is the best way to align a drop-down menu within my DIV container?

Here is the code snippet I am working with: <div id="one"> <a href="#" id="test1" > <button title="test1">test1</button> </a> <a href="#" id="test1" > <button title="test1">test1</button> &l ...

Is it possible to combine form elements into a unified object structure?

Currently, I am working on a project where I need to aggregate form elements into an object and then send it via Ajax. Here is the code snippet that I have started using, but I am stuck on how to proceed further. $('.jcart').live('submit&ap ...

Is there a way to transform a fixed parameter into a user input value and display the function's outcome on a different page?

I am in the process of developing a straightforward web application for book searching based on ISBN. The website will feature a text input field for entering an ISBN and a submit button. Essentially, a user can enter an ISBN in the designated box, click s ...

Using useState props in React Native navigation screens with React Navigation

I'm currently working on my first React Native app with react navigation after previously having a background in web react development. In the past, I typically used useState for managing state. For instance, rendering a list of components based on d ...

Is it possible to create a function that executes if a checkbox is checked, and another function if

When the radio button with the ID m1 is checked, my mesh updates its position. I attempted to make the mesh return to its original position if "#m1" is no longer checked. Is it necessary to trigger a function when checked and a different function when no ...

How can I create a hover effect for multiple divs sharing the same id using CSS or JavaScript in the easiest way possible?

When hovering, I want the opacity to be set at "0.3"; when not hovering, it should be set at "1". Additionally, the color of h2 and h3 in each div should transition from white to red. I have searched extensively online and tried to sol ...

Sometimes the AngularJS scope is refreshed only intermittently

I am encountering an issue with a list of cards retrieved from an API and displayed in a table using ng-repeat. The problem arises when I attempt to delete a card - sometimes it remains in the view, while other times it disappears as expected after confirm ...

I'm feeling a bit lost with this JSON example - specifically with JSON.parse, JSON.stringify, as well as localStorage.setItem

As a beginner in learning JSON, I find that W3schools does not provide clear explanations of what each line of code does. While I can interpret some parts, there are sections that still remain unclear to me. // Data storage process: 1. myObj = {name: "Jo ...

Utilizing jQuery CSS classes to enhance your styles with LESS mixins

Thanks to a tip from another question, I recently stumbled upon LESS. Despite my excitement, I am facing difficulties in making it work as desired. The content of my .less file is as follows: #user_box { .ui-widget-content; .ui-corner-all; po ...

Ways to streamline a form containing several duplicate rows and make it more user-friendly

Looking for some advice on implementing a "working hours" module. Just need something simple like: Monday: 10:00 - 18:00 ... Saturday: 11:00-16:00 with some additional info. I'm currently attempting to... <form id="working_hours"> <s ...

When the if-else statement is executed, it showcases two strings:

Learning Experience: Unveiling My Lack of Cleverness Update: It appears that utilizing PHP in my current setup is not possible. As a result, I'll take some time to contemplate while banging my head against a wall. Despite that, thank you all for your ...

"Latest version of ThreeJS (r160) utilizes ShaderMaterial to render textures

I've been attempting to incorporate a texture into this shader, but it's displaying as black. I suspect there's a small detail I'm overlooking, despite my search yielding no relevant information for ThreeJS version r160. The shader code ...

Is it possible to integrate Firebase Storage into a TypeScript/HTML/CSS project without the use of Angular or React?

For my project, I am aiming to create a login and register page using TypeScript. Currently, my code is functioning well even without a database. However, I would like to implement Firebase for storing user credentials so that the login process becomes mor ...

Using navigator.app.backHistory to navigate back within the app

Currently working on Cordova for Android, incorporating jQuery and jQuery Mobile into my Example App. A slide menu is a key feature of the app, and I am using the "menubutton" event to toggle its visibility based on the global_isOpen variable: document.ad ...

Error in three.js: Attempting to access the 'rotation' property of an undefined object

As I try to animate a cube in my scene, I keep encountering an error that reads: "TypeError: Cannot read property 'rotation' of undefined." function animate() { requestAnimationFrame( animate ); render(); } ...