News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

BBC [CODE] stretches forum horizontally.

Started by Spuddy, February 23, 2010, 06:42:07 AM

Previous topic - Next topic

Spuddy

Is there any way to limit the width a CODE box takes up?

If I use a CODE bbc on my forum regardless of the amount of contents it's way too wide and stretches my forum. Can I limit the code output box to say 500px?

Thanks,

Kays

Hi, welcome to SMF. :)

That shouldn't push the page out but rather it should show scroll bars. Have you tried it in another browser?

The place to do any adjustments is in style.css for the theme you are using. Look for .code. You can add a width there. Also check to see if the overflow is set to scroll

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Spuddy

#2
I apologise, I does indeed add scrollbars however I dislike it and would rather limit the code box width. I will look into the style.css as you mention and let you know.

Thanks.

EDIT: Thanks, changing

width: 99%;

to

width: 600px;

worked

Kays

The thing with the code box is that it was designed that way so it can show a long line of code without breaking it up.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Spuddy

Quote from: Kays on February 23, 2010, 07:23:31 AM
The thing with the code box is that it was designed that way so it can show a long line of code without breaking it up.

Which is fine if the code is actually there. I dislike the fact the box is 99% regardless of whether it contains 2 characters or 222 characters.  :P

Kays

I hear you, quote also. When I used Ikonboard I had that ability. I tried a number of times back when I switched to SMF to do it with no luck.

The problem is that they use division which are at 100% by default. One thing to try, maybe. In Subs.php where the code tag is defined, add a division outside the current one with a small width and overflow as visible. This might force it to a smaller size


If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

MrPhil

The whole point of the code tag is that it does not alter the content by splitting and wrapping lines. You either live with horizontal scroll bars, or use something other than [code]. If what you want is "fixed pitch" text with word-wrap, perhaps you should make a custom BBCode tag based on [code] and [quote] to do that: word wrap like a quote, but use a constant width font. Don't forget to invoke nl2br() so that lines stay separate.

What would be ideal is to have the browser insert a "new line" or "line split" marker character (» or U+00AC or U+21B5) at the point of each word-wrapped line's split. However, I don't know if there's any way in CSS to tell the browser how to do that.

Advertisement: