473,385 Members | 1,630 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,385 software developers and data experts.

Border around <pre> and small screens

Hi,

A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small for
the content. This is because his window size is so small that the size
of the containing <preis smaller than the text in it. Since it is
<pre>, the text is not wrapped, but the border and background color get
smaller. Thus the text pops out of its box.

Is there something one can do against this?

Cheers, H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #1
5 6910
On 2008/06/23 12:45 (GMT+0200) Hendrik Maryns apparently typed:
A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small for
the content. This is because his window size is so small that the size
of the containing <preis smaller than the text in it. Since it is
<pre>, the text is not wrapped, but the border and background color get
smaller. Thus the text pops out of its box.
Is there something one can do against this?
Since most monospace fonts are the same actual width for any given nominal
size, set a width or min-width on the pre block that matches the width the
content requires. That way when the window is wider than it needs to be, the
background and border of the block will be a close fit too instead of being
wider than the content requires.
--
"Where were you when I laid the earth's
foundation?" Matthew 7:12 NIV

Team OS/2 ** Reg. Linux User #211409

Felix Miata *** http://fm.no-ip.com/
Jun 27 '08 #2
Hendrik Maryns wrote:
Hi,

A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small for
the content. This is because his window size is so small that the size
of the containing <preis smaller than the text in it. Since it is
<pre>, the text is not wrapped, but the border and background color get
smaller. Thus the text pops out of its box.

Is there something one can do against this?
No not really. You are giving conflicting rules. PRE in in monospace
font and preserves the whitespace and text newlines to the length of the
PRE text is fixed but the viewport may change...

3 options that I see, adjust the overflow property

pre.example {
padding: 3px 5px; border: 3px double silver;
background: #eee; overflow: auto;
/* causes a scrollbar if content does not fit */
}

pre.example {
padding: 3px 5px; border: 3px double silver;
background: #eee; overflow: hidden;
/* causes content to be clipped */
}

pre.example {
padding: 3px 5px; border: 3px double silver;
background: #eee; width: 20em;
/*
set width to static maximum line width
which is far from elegant and will probably
cause other problems...
*/
}

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jun 27 '08 #3
On 2008-06-23, Hendrik Maryns <gt*******@sneakemail.comwrote:
Hi,

A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small for
the content. This is because his window size is so small that the size
of the containing <preis smaller than the text in it. Since it is
<pre>, the text is not wrapped, but the border and background color get
smaller. Thus the text pops out of its box.

Is there something one can do against this?
You can make the <preshrink-to-fit (or grow-to-fit), by for example

pre { float: left; min-width: 100% }

working around unwanted side-effects as necessary, perhaps with:

pre:after
{
content: "";
display: block;
clear: left;
}

(might not work in IE).
Jun 27 '08 #4
On Mon, 23 Jun 2008 12:45:57 +0200
Hendrik Maryns <gt*******@sneakemail.comwrote in:
g3**********@newsserv.zdv.uni-tuebingen.de
A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small for
the content. This is because his window size is so small that the size
of the containing <preis smaller than the text in it. Since it is
<pre>, the text is not wrapped, but the border and background color get
smaller. Thus the text pops out of its box.

Is there something one can do against this?
You could set display:table; for pre, and since IE does not do
display:table; you could use a conditional comment for IE and set
display:inline; zoom:1;

<style type="text/css">
pre {
display: table;
}
</style>
<!--[if IE]>
<style type="text/css">
pre {
display: inline;
zoom: 1;
}
</style>
<![endif]-->

--
BootNic Mon Jun 23, 2008 3:43 PM
Have no fear of perfection - you'll never reach it.
*Salvador Dali*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkhf/PMACgkQylMUzZO6jeKebQCaAkVbazkhS3mihAvYZZrQarQ2
xTYAnR/8Kl7rxAi2bOVvFhQCTp869KDS
=salh
-----END PGP SIGNATURE-----

Jun 27 '08 #5
Jonathan N. Little schreef:
Hendrik Maryns wrote:
>Hi,

A friend complained that the border around the lower code part on
http://tcl.sfs.uni-tuebingen.de/~hendrik/keyboard.shtml is too small
for the content. This is because his window size is so small that the
size of the containing <preis smaller than the text in it. Since it
is <pre>, the text is not wrapped, but the border and background color
get smaller. Thus the text pops out of its box.

Is there something one can do against this?

No not really. You are giving conflicting rules. PRE in in monospace
font and preserves the whitespace and text newlines to the length of the
PRE text is fixed but the viewport may change...

3 options that I see, adjust the overflow property

pre.example {
padding: 3px 5px; border: 3px double silver;
background: #eee; overflow: auto;
/* causes a scrollbar if content does not fit */
}
I really like this one, thanks!

H.
--
Hendrik Maryns
http://tcl.sfs.uni-tuebingen.de/~hendrik/
==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Jun 27 '08 #6

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

Similar topics

21
by: Headless | last post by:
I've marked up song lyrics with the <pre> tag because it seems the most appropriate type of markup for the type of data. This results in inefficient use of horizontal space due to UA's default...
3
by: Matt Adams | last post by:
I want to move the following <PRE> defintion to a css file: <TABLE><TR><TD><PRE>sample text</PRE></TD> <TD> not predefined font</TD></TR></TABLE> should be <TABLE><TR><TD class=aaa>sample...
1
by: Alan Illeman | last post by:
This is one of several macros I wish to display: <PRE CLASS="special macro> ;; ;; Reverse argument list ;; reverse_args MACRO arglist:req local txt, arg txt textequ <> % FOR arg, <arglist>
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
7
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no...
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...
14
by: Schraalhans Keukenmeester | last post by:
I am building a default sheet for my linux-related pages. Since many linux users still rely on/prefer viewing textmode and unstyled content I try to stick to the correct html tags to pertain good...
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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...
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...

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.