Guest emtx Posted May 6, 2012 Share Posted May 6, 2012 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 More sharing options...
Ingolme Posted May 6, 2012 Share Posted May 6, 2012 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 More sharing options...
Guest emtx Posted May 7, 2012 Share Posted May 7, 2012 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 More sharing options...
Ingolme Posted May 7, 2012 Share Posted May 7, 2012 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 More sharing options...
Guest emtx Posted May 7, 2012 Share Posted May 7, 2012 Alright thanks, I'll move over to the javascript forum then. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now