Liquid + Restriction Height + Copy Text?

Started by G_G, March 31, 2011, 12:00:23 am

Previous topic - Next topic

G_G

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.

G_G


Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

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.

Blizzard

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.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

legacyblade

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.

G_G

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

legacyblade

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.

G_G

Screw I.E. xD

Yea basically I wanted the textbox to fit the number of lines up to a certain point.

legacyblade

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