Chaos Project

General => Electronic and Computer Section => Programming / Scripting / Web => Topic started by: G_G on March 31, 2011, 12:00:23 am

Title: Liquid + Restriction Height + Copy Text?
Post by: G_G on March 31, 2011, 12:00:23 am
Hey guys, I'm trying to create a code box for my web design project.

So here are my thoughts on it. I want a code box which displays code (Obviously). However I want it to have a height restriction. Easy enough, set the height in the CSS style to whatever. However, I don't want it to be that height if theres only one line of code.

Example: One line of code.
hi there

Multiple lines: On my browser, the code box's height gets restricted. (Not sure bout you guys)
lots
of
lines
when
will
this
stop
I
dunno
but
I'm
hoping
soon
well
whatever
...
...
...
...
...
...
...
...
...
...

This is what I'm hoping to achieve. Which gives it a sorta liquid but static height. Any help on this would be gladly appreciated.

Now onto my second question, is there any possible way to copy text using javascript or whatever? Even PHP? (Preferably PHP). Anyways thanks for any bit of help guys.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: G_G on April 06, 2011, 02:22:17 am
Bump?
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: Blizzard on April 06, 2011, 02:27:20 am
You can only use PHP to generate a site, not edit it afterwards while it's still loaded without having to reload it. That's what Javascript is for.
Just throwing it out there to point you in the right direction. You will probably have to do this with Javascript if I understand right what you want to do.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: G_G on April 06, 2011, 02:33:02 am
Yea figured. Would you know how to have a method in javascript constantly get called? Like an update method? Maybe then I can just have it check elements height and set the height manually.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: Blizzard on April 06, 2011, 03:04:30 am
I think you have to implement a callback event "on_text_changed" or something in that manner (similar to how C# works) and then change it there. There is no constant update in websites like in other applications.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: legacyblade on April 23, 2011, 02:46:01 am
A good way to do this would be to use javascript to check the amount of text in the box, then change the box's class (or even a single attribute) via javascript if there's a certain amount.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: G_G on April 24, 2011, 01:04:54 pm
Theres a CSS property called max-height. I discovered this when peaking at a themes CSS style sheet for chaos project. I found the code box style and found it. :S You guys lied to me :V
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: legacyblade on April 25, 2011, 07:55:30 pm
It sounded like you wanted it to look a certain way when there was only one line :P Max-height (I thought anyways) was basic knowledge. It doesn't work on internet explorer though.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: G_G on April 25, 2011, 09:04:13 pm
Screw I.E. xD

Yea basically I wanted the textbox to fit the number of lines up to a certain point.
Title: Re: Liquid + Restriction Height + Copy Text?
Post by: legacyblade on April 28, 2011, 10:46:25 pm
I agree. IE is the most annoying backwards browser ever. Trying to get layouts to not break on IE is a nightmare for quite a few things. It literally costs thousands of extra dollars for companies because of the mountain of extra time and effort making things look good on IE requires. (some layouts look like crap without min/max with/height settings, the inability to use the inline-block attribute, how older IE versions handle PNG transparency, absolute positioning errors, etc).

I say down with IE :P