473,382 Members | 1,733 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,382 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 11438
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.