JQuery's accordion with the heightStyle set to "fill" is causing a vertical scrollbar

I recently integrated the JQuery accordion effect into my website and specified the heightStyle: fill so that it would occupy the entire window.

However, it seems to be taking up an additional 1 or 2 pixels, causing the vertical scroll bar to appear. I suspect there might be extra padding or margin causing this, but despite trying everything, I am unable to pinpoint the source of these extra pixels.

Any ideas on where this is coming from? I just want it to expand to fill the whole page without triggering the vertical scrollbar.

Live Example: http://jsfiddle.net/r2Vra/ (You will need to re-run if you resize the result window)

HTML:

<body>
    <div id="palette">
        <div id="accordion">
          <h3>Upper Case</h3>
          <div id="upperCase"></div>
          <h3>Lower Case</h3>
          <div id="lowerCase"></div>
          <h3>Numbers</h3>
          <div id="numbers"></div>
          <h3>Punctuation</h3>
          <div id="punctuation"></div>
        </div>
    </div>
    <div id="canvas">
        <div id="trash"><a href="#"></a></div>
    </div>
</body>

CSS:

/****************************************************************************************
* GENERAL
*****************************************************************************************/

html, body {
height: 100%;
margin: 0;
padding: 0;
}

/****************************************************************************************
* PALETTE
*****************************************************************************************/

#palette {
float: left;
width: 320px;
height: 100%;
background-color: #888;
padding: 0 5px;
background: url(../img/texture.png) repeat;
}

#palette .letter {
    font-family: 'Chango', cursive;
    display: inline-block;
    font-size: 4em;
    text-shadow: 2px 2px 1px rgba(0, 0, 0, 1);
    cursor: move;
}


/****************************************************************************************
* CANVAS
*****************************************************************************************/

#canvas {
margin-left: 320px;
height: 100%;
z-index: 0;

background: url(../img/refrigerator.jpg) no-repeat center center fixed;
background-position: left 200px center;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover; 
}

#canvas .newLetter {
    font-family: 'Chango', cursive;
    display: inline-block;
    font-size: 4.4em;
    text-shadow: 2px 2px 1px rgba(0, 0, 0, 1);
    cursor: move;
}

#trash {
position:fixed;
right:0;
bottom:10px;
z-index: 100;
}

#trash a{
display: block;
background: url(../img/trashcan-sprite-tiny2.png) no-repeat;
height: 110px;
width: 125px;
}

#trash a:hover{
background-position: 0px -113px;
}

#trash img {
border: none;
}

/****************************************************************************************
* JQUERY UI CSS OVERRIDE
*****************************************************************************************/

#accordion .ui-accordion-content {
    padding: 0 .5em;
}

/*
.ui-helper-reset {
line-height: 1.2;
}

.ui-widget {
font-size: 1em;
} */

JavaScript:

$(function() {
    $( "#accordion" ).accordion({ heightStyle: "fill" });
});

Answer №1

After some trial and error, I managed to come up with a solution that suits my needs.

To achieve this, I simply introduced an additional div element and adjusted its dimensions to be slightly smaller than its parent div.

Keep in mind: It is a tad disappointing that I had to resort to adding another div. If anyone has a different approach, I'd be interested to hear it.

HTML:

    <div id="palette">
        <div id="container">
            <div id="accordion">
              <h3>Upper Case</h3>
              <div id="upperCase"></div>
              <h3>Lower Case</h3>
              <div id="lowerCase"></div>
              <h3>Numbers</h3>
              <div id="numbers"></div>
              <h3>Punctuation</h3>
              <div id="punctuation"></div>
            </div>
        </div>
    </div>

CSS:

#container {
    height: 99.5%;
}

Answer №2

To address this issue, simply include the following code:

#accordion .ui-accordion-content {
    margin-bottom: -2px;
}

While it may not be a flawless solution, it does get the job done.

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

Guide to using react-router for redirection and displaying messages

Is there a way in React to redirect after a successful login with a success message displayed on another component? I previously used flash messages, but they didn't integrate well with react-router and caused full page refreshes. Now that I am using ...

I am in the process of extracting information from the database, but I encountered an error stating that the variable $request is undefined

My controller contains a method called request, which retrieves data from the database and then compacts the variable with the view. <?php namespace App\Http\Controllers\Admin; use App\Http\Controllers\Controller; use ...

Spacing for Bootstrap Navbar List Items

I've searched through the CSS and I'm unable to identify what is causing the width between the top level links on my navbar. I need them to be slightly smaller so that when it adjusts for a screen below 900px, it doesn't convert into a 2-row ...

Adjust the size of a div using jQuery while toggling text

Seeking help for expanding a div when text toggle overflows current size due to mouse click. Current issue results in text overlapping the containing div. Toggle Function: $(document).ready(function(){ $(".parents-toggle > div").click(function () { $( ...

PhantomJS 2.0.0 not delaying page loading

In the script provided, there is an array of URLs called links. The function gatherLinks() is designed to collect additional URLs from the sitemap.xml file related to the ones in the links array. Once the number of URLs in the links array reaches a certain ...

Add() function is not duplicating the formatting

I'm attempting to replicate the content below inside a DIV. <ul class="pie-legend"><li><span style="background-color:#0066CC"></span>10-0-1</li><li><span style="background-color:#33CC33&q ...

Vuejs unstyled content flash

I encountered an issue while loading a page with Vue. Initially, I am able to access variables like @{{ value }} but once the page is fully loaded, the variable becomes invisible. How can I resolve this issue? I have already included Bootstrap and all scri ...

What is the best way to prevent automatic trimming in EJS variable assignment in Node.js?

When I attempt to write a variable from the database into an EJS table, it is being displayed with default trimming by the EJS template. However, I would like to display the variable from the database without any default trimming. I consulted the EJS temp ...

Retrieve information from MySQL database with jQuery upon button click

After fetching multiple data rows from a MySQL database and displaying them in a table, I want to include a button in the last column of each row. The unique ID for each button will be retrieved from the database. When a user clicks on any of these buttons ...

updating a d3js line graph in real-time using JSON information

Trying to wrap my head around dynamically updating a line graph with new data, shifting the graph to the left and adding fresh data from the right - you following me? Want it to behave just like the examples on I'm fairly new to d3 (javascript) and l ...

Assign a class to the element only when the second div also has a class

I am trying to create a functionality where I have a dropdown element (Li element) that receives an Active class when its parent div (button) is clicked. When the dropdown element has this class, I want to assign the same class to another div. If the dropd ...

An even flexbox grid featuring content of varying sizes and dividers

I am currently in the process of working on a .psd template and utilizing Bootstrap 4. I have encountered an issue with one section that contains multiple rows and columns with varying content. The main problem is with one column where the text inside the ...

Automate the process of filling up and activating a bootstrap dropdown upon a click, and clearing it out when it is

Is there a method to reveal the dropdown content only upon clicking instead of displaying all content at once and increasing the lines of HTML code? Perhaps using an onclick attribute on the button and incorporating a function inside? var data = [{ " ...

Looking to transform a nested JSON structure into a visually appealing HTML table with merged rows?

My JSON structure appears as follows: $scope.data = [ { "type":"Internal", "count": 3, "library" : [ { "type":"Library 123", "count": 2, "version" ...

Define the input field as a specific type and disable the Material-UI text formatting

I am using a Texfield component from Material UI, but I have noticed that every time I type, the input stops and doesn't continue to the next letter. I have to click on it again in order to continue typing. When I remove the onChange method, the data ...

substitute the character ""<0x00>"" within the given string

I'm currently facing an issue with a string I received after sending a command line that included the <0x00> character. How can I remove it from the string? For instance, here is my variable string: <0x00> awplus # desired output: awplus ...

JavaScript tabs function malfunctioning upon page load

I attempted to implement tabs on my website using this example: http://www.w3schools.com/howto/howto_js_tabs.asp Although everything is functioning correctly, the default tab isn't opening as expected. The tab opens, but the header color does not get ...

What's the best way to ensure these have equal heights?

There seems to be a difference in height between the verses at the bottom, and I want each verse next to each other to have equal heights. Here is my current code setup: .verse img { height: 1em; } <h1>PSALM 1</h1> <p> <div> ...

Creating a mobile-friendly layout with 3 columns: Tips and tricks

I attempted to solve the issue independently but didn't have much success. My goal is to create a proper version for mobile users using bootstrap, however, it currently looks terrible on mobile devices. I suspect the problem lies with the div classes ...

What is the best way to implement this header style with code?

I came across this design from a potential client recently, even though we didn't end up working together. I thought it would be a good exercise to try coding the design for practice purposes. Just to clarify, this is not my original design and I have ...