473,395 Members | 1,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

pre-formated text with scroll bars at 100% width

I have a table that is at 100% width, which contains a <TD> that is
80% of that. In the <TD> I want to put pre-formatted text (the output
from a C++ compiler, to be more precise) and I'd like the text to use
scroll bars if it does not fit.

I can't get this to work, no matter what combination of <PRE>, width,
and style I try. Any help greatly appreciated.

Thanks,
Emil
Jul 20 '05 #1
3 11439
em***@collectivestudios.com (Emil Dotchevski) wrote:
I have a table that is at 100% width, which contains a <TD> that is
80% of that.
I have a feeling that you are using a table for layout in a manner that
could be replaced easily by the use of CSS.
In the <TD> I want to put pre-formatted text (the output
from a C++ compiler, to be more precise) and I'd like the text to use
scroll bars if it does not fit.
You cannot do such things in HTML in any convenient and useable way,
though some people might suggest that you use <iframe> or "normal"
frames; the latter would be suggested as an overall page design
"solution", whereas <iframe> could actually appear inside a cell.
I can't get this to work, no matter what combination of <PRE>, width,
and style I try. Any help greatly appreciated.


Well, you didn't actually describe what you tried.

But the width attribute of <PRE> is not much supported, and it's
defined meaning is not related to scrolling, so it was somewhat futile
if you tried that.

The natural approach, in the modern world, is to use CSS. The details
belong to c.i.w.a.stylesheets, but just to give an idea: if this is the
only table element on the page, you could use

<style type="text/css">
table { table-layout: fixed; }
table pre { width:100%;
overflow: auto;
line-height: 1;
height: 11em;
margin: 0; }
</style>

where the number 11 is to be replaced by a number that is the number of
lines in the <pre> element plus one. (The plus one comes from a guess
of how much vertical space the horizontal scroll bar needs.)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #2
Yes, I am using CSS, and overflow: scroll. Here is what I tried:

<table width="100%">
<tr>
<td width="20%">Compiler Output</td>
<td width="80%">
<pre style="WIDTH: 100%; overflow: scroll">
c:\program files\microsoft visual studio .net
2003\vc7\include\xtree(1116) : warning C4702: unreachable code
c:\program files\microsoft visual studio .net
2003\vc7\include\xtree(1117) : warning C4702: unreachable code
c:\program files\microsoft visual studio .net
2003\vc7\include\xtree(1118) : warning C4702: unreachable code
c:\program files\microsoft visual studio .net
2003\vc7\include\xtree(1119) : warning C4702: unreachable code
c:\program files\microsoft visual studio .net
2003\vc7\include\xtree(1121) : warning C4702: unreachable code
</pre>
</td>
</tr>
</table>

What I want it to look like is this: a table with 100% width, with one
row, two cells: one 20%, the other 80% of the table width. The one
with 80% width I want to have scroll bars and display the <pre> text.
I do not want the table to overflow the browser window.

This works fine in Netscape. It does not work in IE.

I tried to put the <pre> out of the table and specify
style="width:100%" and it worked fine. Somehow the fact that it is
inside a table breaks it.

Any help appreciated.

--Emil
Jul 20 '05 #3
em***@collectivestudios.com (Emil Dotchevski) wrote:
Yes, I am using CSS, and overflow: scroll. Here is what I tried:
So you pretty much tried what I suggested, except that you don't use
table-display: fixed, which really makes a difference.
What I want it to look like is this: a table with 100% width, with
one row, two cells: one 20%, the other 80% of the table width.
Why? It is debatable whether your example logically has tabular data,
but in any case "Computer Output" is logically a heading and now wastes
valuable horizontal space, so it would be natural to put it before the
<pre> - and use normal horizontal scrolling for the page as a whole if
the preformatted text doesn't fit.
I tried to put the <pre> out of the table and specify
style="width:100%" and it worked fine. Somehow the fact that it is
inside a table breaks it.


Browsers may use information about the cell contents when deciding on
column widths, overriding your width suggestions. Using the
table-layout property may prevent this.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Porthos | last post by:
Hi All, I'm building an XSL document that puts two types of information in a table dimension: preformatted data and data extracted from my XML document (see below) <table> <tr>
8
by: Jarno Suni not | last post by:
It seems to be invalid in HTML 4.01, but valid in XHTML 1.0. Why is there the difference? Can that pose a problem when such a XHTML document is served as text/html?
4
by: bryan | last post by:
I'm still using Beta 2 of VS2005. I'd like to be able to precompile my web site (similar to 1.x) so that I don't have to put source files on the deployment server. Is there anyway to do this other...
9
by: Eric Lindsay | last post by:
I can't figure how to best display little snippets of shell script using <pre>. I just got around to organising to bulk validate some of my web pages, and one of the problems occurs with Bash...
23
by: Xah Lee | last post by:
The Concepts and Confusions of Pre-fix, In-fix, Post-fix and Fully Functional Notations Xah Lee, 2006-03-15 Let me summarize: The LISP notation, is a functional notation, and is not a...
10
by: Xah Lee | last post by:
there's a HTML odditity. That is, line break will be ignored inside <preif the adjacent lines are tags. see the source code and description here: http://xahlee.org/js/linebreak_after_tag.html...
7
by: Paul Connolly | last post by:
char *s = "Hello"; s = 'J'; puts(s); might print "Jello" in a pre-ANSI compiler - is the behaviour of this program undefined in any pre-ANSI compiler - or would it always have printed "Jello"...
2
by: Mitoshima | last post by:
The pre-alpha version of Tic Tac Toe Plus, which is actually a Tic Tac Toe game, will be made available on Wed 27th. Your contribution is needed and will be appreciated as we would like persons...
2
by: yashgt | last post by:
Hi, We have a virtual directory MyApp that uses ASP .NET v2.0.50727, under which we have kept the source code(aspx, ascx and vb), as well as a bin directory in which we have the pre-compiled...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.