Log in

No account? Create an account
Previous Entry Share Next Entry
Slidy text
annomalley wrote in webdesign
Hi all,

I was hoping y'all might know how to do this: my clients keep asking me for links that when clicked on reveal text on the same page. Is there some hide/display CSS wizardry I can use for this or a nice cross-platform javascript, or will I have to make these sites in Flash?

  • 1
you can use js to change a css attribute: visibility

heh heh you replied before I finished editing my post to ask about that...

I just got done tinkering with this, and some JS code that will work with the w3's CSS is:

function show(div)
var x = document.getElementById(div);
x.style.visibility = "visible";
function hide(div)
var x = document.getElementById(div);
x.style.visibility = "hidden";

You could have the buttons (links, etc.) also specify the element directly, instead of quoting the name of the element like on the w3 example and thus avoid the first step in each function.

Good luck.

Sweet - I shall try this shortly. Thanks!

Yup, it's taken me this long to actually try this, and I admit defeat - I don't understand it... I take it there are some extra bits I need to put into the navigation? Forgive me but I don't know JS...

since we're on the topic, what's the difference between setting the css attribute display to none and setting visibility to hidden?

ops. should follow your links before asking stupid questions:

(from the link post by xiota)
The 'visibility' property specifies whether the boxes generated by an element are rendered. Invisible boxes still affect layout (set the 'display' property to 'none' to suppress box generation altogether).

so i was correct in using display.. that was what i really needed. :)

  • 1