Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 181407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:45:29+00:00 2026-05-11T14:45:29+00:00

I’m trying to modify the Simple jQuery Slideshow published by Jonathan Raasch. It cycles

  • 0

I’m trying to modify the Simple jQuery Slideshow published by Jonathan Raasch.

It cycles through all images fading from each to the next.

350px square image in a 350px height DIV container http://img154.imageshack.us/img154/904/fixed.jpg

His example works with fixed-size images. I want it to instead work with images sized to a percentage width of the browser window.

This works with fixed-size images…

#slideshow {     ...     height:350px; }  #slideshow img {     ... } 

This is how I changed it…

#slideshow {     ... }  #slideshow img {     ...     width: 50%; } 

Becasue I’m no longer explicitly setting the height of the DIV ‘slideshow’, it collapses to 0. And the image then covers up my text. Compare…

50% wide image in a zero height DIV container (overlaps text) http://img253.imageshack.us/img253/6016/variable.jpg

This is my whole HTML file including CSS and JavaScript…

<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'> <html xmlns='http://www.w3.org/1999/xhtml' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xml:lang='en'>     <head>         <title></title>         <style type='text/css'>              #slideshow {                 position:relative;                 height:350px;             }              #slideshow img {                 position:absolute;                 top:0;                 left:0;                 z-index:8;             }              #slideshow img.active {                 z-index:10;             }              #slideshow img.last-active {                 z-index:9;             }          </style>         <script src='js/jquery-1.3.2.min.js' type='text/javascript'></script>         <script type='text/javascript'>              function slideSwitch() {                 var $active = $('#slideshow img.active');                 if ( $active.length == 0 ) $active = $('#slideshow img:last');                 var $next =  $active.next().length ? $active.next()                     : $('#slideshow img:first');                 $active.addClass('last-active');                 $next.css({opacity: 0.0})                     .addClass('active')                     .animate({opacity: 1.0}, 1000, function() {                         $active.removeClass('active last-active');                     });             }              $(function() {                 setInterval( 'slideSwitch()', 5000 );             });          </script>     </head>     <body>          <div id='slideshow'>             <img src='img/img1.jpg' alt='' class='active' />             <img src='img/img2.jpg' alt='' />             <img src='img/img3.jpg' alt='' />         </div>          <p>Lorem ipsum ...</p>      </body> </html> 

Why is my DIV smaller than its contents? How can I make my DIV height match the height of its contents?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:45:30+00:00Added an answer on May 11, 2026 at 2:45 pm

    The absolute positioning is the reason the images are over the text (since nothing is giving the #slideshow <div> any height), but your system needs the images to be absolutely positioned in order to stack them on top of each other for the slideshow effect. Since you are using jQuery anyway, you can programmatically expand the container <div> to the height of the largest image.

    var maxHeight = 0; $('#slideshow img').each(function(){     if (maxHeight < $(this).height()) {maxHeight = $(this).height()} }); $('#slideshow').height(maxHeight); 

    I’m sure someone can point out a more elegant way to write the maxHeight part of the script!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to loop through a bunch of documents I have to put
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.