| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
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. |
|
|
|
|
|
#4 (permalink) |
|
Registered User
|
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! |
|
|
|
#5 (permalink) |
|
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. |
|
![]() |