Jump to content

Expanding text box


Guest emtx

Recommended Posts

Guest emtx

Hi There, I want to create a text box that can expand and contract using css. If this is possible, can you help me out?I have played with things like this which seems annoyingly close to what I want:

<html><head><style type="text/css">div.test{white-space: nowrap;width:200px;height:20px;overflow:hidden;border:1px solid #000000;text-overflow: '...';}div.test:active{height: auto;white-space: normal;}</style></head><body><div class="test">This is some text This is some text This is some text This is some text This is some text This is some text This is some text </div></body></html>

But I want the box to remain large after clicking, and another click will make it small again. Can this be done?

Link to comment
Share on other sites

It can be done, but not with CSS. You would need to use Javascript. Just attach an onclick event to the box and set the height.

Link to comment
Share on other sites

Guest emtx

Ok, is there a way to do that without adding any coding to the <div>? (the div is going to be generated html that I can't edit) Or is there a way to have the css text-overflow actually add an html link?

Link to comment
Share on other sites

You can add events to elements without actually changing the HTML of the element. CSS cannot do what you're asking for.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...