Webforumz's RSS FeedRSS Webforumz RegistrationRegister Contact Webforumz StaffContact

Show and hide content using CSS

This is a discussion on "Show and hide content using CSS" within the Web Page Design section. This forum, and the thread "Show and hide content using CSS are both part of the Design Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Design Your Website > Web Page Design

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jul 21st, 2008, 13:07
Junior Member
Join Date: Aug 2006
Location: Lancashire, UK
Age: 28
Posts: 36
Thanks: 3
Thanked 0 Times in 0 Posts
Show and hide content using CSS

Hi,

I want to swop some content in a page out without the page re-loading, basically I have 3 'tabs' each with a little text content associated with them, I would like to show tab 1's content and when clicked for it to be replaced with tab 2 or 3's content. I would imagine it's possible using show/hide with javascript and css.

I have found some simlar things around but none that 'replace' the entire content area.

Thanks,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #2  
Old Jul 21st, 2008, 16:29
Elite Veteran
Join Date: Aug 2005
Location: That Place
Posts: 2,044
Blog Entries: 1
Thanks: 0
Thanked 37 Times in 37 Posts
Re: Show and hide content using CSS

It can be done with CSS alone, however if you want it to be "Sticky" you would need js to accomplish this. The nice thing is when its done with CSS and you append js to it it will function with or without javascript enabled.

I have a menu example here I built which uses just css and you can also use something like jQuery to very easily add the js functionality. Hope this helps.
__________________

Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jul 21st, 2008, 16:30
Reputable Member
Join Date: Jul 2008
Location: UK and Spain
Age: 24
Posts: 104
Thanks: 2
Thanked 14 Times in 13 Posts
Re: Show and hide content using CSS

you could use the

Code: Select all
display: block;
and

Code: Select all
display: none;
style tags for the div columns you want to show and hide, have each "tab" as a separate div?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Jul 21st, 2008, 17:35
Elite Veteran
Join Date: Aug 2005
Location: That Place
Posts: 2,044
Blog Entries: 1
Thanks: 0
Thanked 37 Times in 37 Posts
Re: Show and hide content using CSS

Its a lot more effective if it is done using unordered lists and nested unordered lists for the show/hide as you need to have an item that can easily and direcetly activate display/hide of the required elements. th eonly reason I recommened jQuery is that with it he can add animation effects and easily handle the show/hide and make it sticky. CSS while it is possible the :active psuedo class only gets you so far and it is a tad more complex of an implementation.

The example i provided shows this and can be easily dissected and used for a base. Salbert if you need any other help just let us know.

Simplest example would be:

Code: Select all
#foo ul li ul {display:none;}
#foo ul li:hover ul {display:block; position:absolute; width:200px;}
__________________

Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)

Last edited by moojoo; Jul 21st, 2008 at 17:50.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Jul 22nd, 2008, 14:30
Reputable Member
Join Date: Jul 2008
Location: UK and Spain
Age: 24
Posts: 104
Thanks: 2
Thanked 14 Times in 13 Posts
Re: Show and hide content using CSS

sorry, I was writing mine out while you posted your first reply moojoo, didn't see it till after I'd posted! yours is the better option!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Jul 22nd, 2008, 15:36
Elite Veteran
Join Date: Aug 2005
Location: That Place
Posts: 2,044
Blog Entries: 1
Thanks: 0
Thanked 37 Times in 37 Posts
Re: Show and hide content using CSS

Quote:
Originally Posted by stu2000 View Post
sorry, I was writing mine out while you posted your first reply moojoo, didn't see it till after I'd posted! yours is the better option!
Your response was not incorrect, just thought it was a bit vague for what he was looking for.
__________________

Last Blog Entry: Apps every Mac based web dev should consider (Jul 10th, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Jul 23rd, 2008, 19:12
Aso's Avatar
Aso Aso is online now
Moderator
Join Date: Oct 2007
Location: UK
Posts: 1,536
Blog Entries: 2
Thanks: 19
Thanked 81 Times in 76 Posts
Re: Show and hide content using CSS

Just another solution - if you want something out-of-the-box and degrades nicely, I've used 'Tabber' in the past which is dead easy to use
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
css, hide, show

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flash content resets, when javascript hide / show is used (prob in firefox, IE fine) call14 Flash & Multimedia Forum 0 Feb 4th, 2008 17:12
CSS Show Hide with JS abis123 JavaScript Forum 4 Dec 13th, 2007 06:39
[SOLVED] Show&Hide Div Box Maska JavaScript Forum 6 Oct 1st, 2007 12:04
Show/Hide JS pa007 JavaScript Forum 0 Apr 6th, 2007 20:18
Show/Hide Div Help Trebz JavaScript Forum 2 Feb 21st, 2006 23:37


All times are GMT. The time now is 19:07.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8