How can I address having a responsive height to a div with the content that is passed into it from a JSON file?
-
Intent The containing div and body should have a responsive height according to the content. Currently if the description is larger than the body, it will extend down into the footer. Background The content is being populated on the page from a JSON file, the content is alternated with jQuery cycle, into a MustachJS template. I ended up having to implement min-height. But this is causing a problem if the browser is at a height lower than a certain point. Here is my code HTML <div id="casesContainer"> <div class="image-navigation"> <div class="image-navigation-previous"> <a href="#" id="prev_btn">« Previous</a> </div> <div class="image-navigation-next"> <a href="#" id="next_btn">Next »</a> </div> </div> <!-- end of image-navigation --> <div id="carousel"></div> </div><!-- end of #casesContainer --> <script id="casestpl" type="text/template"> {{#cases}} <div class="case"> <div class="gallery_images_container"> <div class="item_container"> <div class="gallery_heading">BEFORE</div> <img src="/assets/img/content/images-bruxzir-zirconia-dental-crown/cases/{{image}}_b_320.jpg" alt="Photo of {{alt}}" /> </div> <div class="item_container"> <div class="gallery_heading">AFTER</div> <img src="/assets/img/content/images-bruxzir-zirconia-dental-crown/cases/{{image}}_a_320.jpg" alt="Photo of {{alt}}" /> </div> </div> <div class="description_container" style="min-width:310px;"> <p> <span><strong>Case Number {{{number}}} {{version}}:</strong></span> {{{description}}} </p> </div> </div> {{/cases}} </script> CSS #carousel { height:100%; min-height:600px; } .case { max-width: 640px; height:auto; } .gallery_images_container { clear: both !important; } .item_container{ max-width: 320px; float: left; } .gallery_heading { background: black; color: white; width: 100%; text-align: center; } .description_container { min-width: 308px; max-width: 640px; padding: 6px 6px 12px 6px; clear: both !important; } JavaScript $(function() { $.getJSON('/pages/cases-bruxzir-zirconia-dental-crown/cases.js', function(data) { var template = $('#casestpl').html(); var html = Mustache.to_html(template, data); $('#carousel').html(html); $('#carousel').cycle({ pause: 1, speed: 500, timeout: 10000, slideResize: true, containerResize: true, width: '100%', height: '100%', fit: 1, fx: 'fade', next: '#next_btn', prev: '#prev_btn' }); }); //getJSON }); //function Question has been posted to Stackoverflow but maybe I did not ask in the most clear way. http://stackoverflow.com/questions/17034114/how-to-create-a-responsive-height-for-a-div-whose-content-is-dynamically-generat
-
Answer:
Why not add a overflow: hidden; max-height: ####px; To your code? I'm unclear about what you expect to see at.
Giordon Stark at Quora Visit the source
Related Q & A:
- How can I programmatically extract a file quickly and efficiently within Android?Best solution by Stack Overflow
- How can I tell how long I've been a member of Yahoo?Best solution by answers.yahoo.com
- How can I find Yahoo email address with only a full name?Best solution by Yahoo! Answers
- How can I get into a graduate program without a stellar GPA?Best solution by answers.yahoo.com
- How can I attach more than one file at a time in Yahoo mail?Best solution by pc.net
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.