Old 19-05-2008, 23:35   #1 (permalink)
gloomer
Registered User
 
Join Date: Oct 2007
Posts: 3
Expanding content

How does expanding content work? Basically a section expanding because of more content. I'm not sure what needs to happen for this. I've never coded anything with expanding content before, so will I need something like Javascript alongside CSS and HTML?

Thanks for answering my questions about this.
  Reply With Quote
Old 19-05-2008, 23:54   #2 (permalink)
Shiro
shiro
 
Shiro's Avatar
 
Join Date: Aug 2007
Location: Yokohama, Japan
Posts: 2,630
If you don't set a height to an element, the element will expand to hold the content.
__________________
This space for rent.

Dads Japan
After Hours Japan
  Reply With Quote
Old 22-05-2008, 04:12   #3 (permalink)
Mongoose
Senior Member
 
Mongoose's Avatar
 
Join Date: Oct 2007
Location: Olympia, WA
Posts: 150
Send a message via AIM to Mongoose
If you want pretty animations to go along with the expanding sections, look into Javascript libraries like jQuery or Mootools.
__________________
  Reply With Quote
Old 22-05-2008, 11:12   #4 (permalink)
robdesign
Registered User
 
Join Date: May 2008
Posts: 62
Send a message via AIM to robdesign Send a message via MSN to robdesign
It's easy. Just set a min-height (in css) on whatever your expanding. This way, the content will still hold it's regular height if theres no content, but if it overflows then the content will expand.

for example:
#content {
min-height: 500px;
}

The #content will be 500 pixels in height if there is no overflow, but it will expand to hold extra content. Hope this helps!
  Reply With Quote
Old 23-05-2008, 09:30   #5 (permalink)
karmedic
id
 
Join Date: May 2008
Location: Ottawa
Posts: 217
If I understand you correctly you'd like to show more content that's hidden on initial load - is that correct? if so here's a simple js function that doesn't require libraries to work:

function toggle(d){
if(document.getElementById(d).style.display == 'none'){
document.getElementById(d).style.display = 'block';
}else{
document.getElementById(d).style.display = 'none';
}
}

you would call it in such a way:

<h1>some title</h1>
<p>abstract of the content .. maybe a first paragraph or so...</p>
<a href="javascript:toggle('morecontentcontainer');"> more...</a>
<p id="morecontentcontainer" style="display: none;">more content goes here .... </p>

This isn't tested but is pretty simple and should get you started.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8