I added a jQuery UI accordion here: http://www.letmagichappen.com/web_resources to accommodate a large amount of data. The accordion works fine, but the size of the content area is much larger than needed for the content.
I reviewed the css:
.web_resources .ui-accordion { width: 100%; }
.web_resources .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; }
.web_resources .ui-accordion .ui-accordion-li-fix { display: inline; }
.web_resources .ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; }
.web_resources .ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; }
.web_resources .ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.web_resources .ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
.web_resources .ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; }
.web_resources .ui-accordion .ui-accordion-content-active { display: block; }
The HTML is pretty straight forward:
<h4>Chapter 1</h4>
<div>
<p><a href="http://www.ajronline.org/content/153/1/87.full.pdf">Rotator Cuff Tears: Prospective Comparison of MR Imaging with Arthrography, Sonography, and Surgery</a></p>
<p><a href="http://www.nejm.org/doi/pdf/10.1056/NEJM199407143310201">Magnetic Resonance Imaging of the Lumbar Spine in People without Back Pain</a></p>
<p><a href="http://www.ajronline.org/content/147/2/293.full.pdf+html">1.5 Tesla Surface Coil MRI of the Knee</a></p>
<p><a href="http://www.yogaresearchsociety.com/">Yoga Research Society</a></p>
<p><a href="http://www.rsna.org/">Radiological Society of North America</a></p>
<p><a href="http://www.apple.com">Sample 1</a></p>
</div>
Here is the code for the Accordion:
<script type="text/javascript">
$(function(){
$(".web_resources").accordion({ header: "h4" });
});
</script>
I would appreciate some insights into what is causing the content area to display so big and how to bring it under control.
Thanks!
2 answers
point
Chapter 15 is large and takes up that given area. The accordion will, by default take up enough space to fit the longest element. To turn this off, use autoheight: false in your options for initialization.
- Thanks for the help on that. Any idea why the content "jumps" now when I click on the different chapters links?
points
Thanks for the help on that. Any idea why the content "jumps" now when I click on the different chapters links?
- This was caused by the content "bumping" up against the neighboring block. I reduced the width from 100% to 96% and smooth accordion action returned.
