Scroll bar inconsistencies in Firefox vs. Chrome

D

Disc Magnet

If I wrap a <pre> with style as "overflow: auto" inside a <div> with
style as "word-wrap: break-word;" I get this behavior:

* No scroll bar in Chrome; long lines wrap.
* Long text causes scroll bar to appear in Firefox.

The behavior I need is scroll bar appearing for long lines in all
browsers. Here is the code (also available at http://www.webdevout.net/test?01q
for sometime). Please help.

<html>
<head><title>Console Effect</title>
<style type="text/css">
..wrap {
word-wrap: break-word;
}

pre {
width: 50em;
padding: 2px 5px;
background: #000000;
color: #bbbbbb;
overflow: auto;
}
</style>
<head>
<body>
<p>
Foo
</p>
<div class="wrap">
<pre>
123456789 123456789 123456789 123456789 123456789 123456789 123456789
123456789 1234567890

int main()
{
printf("hello, world\n");
}
</pre>
<p>
Bar
</p>
</div>
</body>
 
1

123Jim

Disc Magnet said:
If I wrap a <pre> with style as "overflow: auto" inside a <div> with
style as "word-wrap: break-word;" I get this behavior:

* No scroll bar in Chrome; long lines wrap.
* Long text causes scroll bar to appear in Firefox.

The behavior I need is scroll bar appearing for long lines in all
browsers. Here is the code (also available at
http://www.webdevout.net/test?01q
for sometime). Please help.

<html>
<head><title>Console Effect</title>
<style type="text/css">
.wrap {
word-wrap: break-word;
}

pre {
width: 50em;
padding: 2px 5px;
background: #000000;
color: #bbbbbb;
overflow: auto;
}
</style>
<head>
<body>
<p>
Foo
</p>
<div class="wrap">
<pre>
123456789 123456789 123456789 123456789 123456789 123456789 123456789
123456789 1234567890

int main()
{
printf("hello, world\n");
}
</pre>
<p>
Bar
</p>
</div>
</body>

Take a look here:
http://myweb.tiscali.co.uk/ladycroft/ConsoleEffect.html
It's closer to what you want I think, Chrome, IE and firefox (latest
versions) display the same, no vertical scrollbar. There is a new problem
however.. blank lines ..(I'll take a look at that later)
Here's the modified markup:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Console Effect</title>

<style type="text/css">
..wrap {
padding: 2px 5px;
background: #000000 none repeat scroll 0% 50%;
color: #bbbbbb;
width: 50em;
font-family: monospace;
overflow: auto;
white-space: pre;
}

</style></head>
<body>
<p>
Foo
</p>
<div class="wrap">
123456789 123456789 123456789 123456789 123456789 123456789 123456789
123456789 234567890<br>
int main()<br>
{<br>
printf("hello, world\n");<br>
}<br>
</div>
<p>
Bar
</p>
</body></html>
 
1

123Jim

Take a look here:
http://myweb.tiscali.co.uk/ladycroft/ConsoleEffect.html
It's closer to what you want I think, Chrome, IE and firefox (latest
versions) display the same, no vertical scrollbar. There is a new problem
however.. blank lines ..(I'll take a look at that later)
Here's the modified markup:

OK I had to update this .. Kompozer was placing <br> throughout the code in
the <div> pretending to be <pre> .. That explains the blank lines, now
fixed. The only problem I see now is IE is choosing larger fonts than Chrome
and Firefox .. I'm sure someone will have the answer before I figure it out
;)

Updated Markup:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head><title>Console Effect</title>

<style type="text/css">
..wrap {
padding: 2px 5px;
background: #000000 none repeat scroll 0% 50%;
color: #bbbbbb;
width: 50em;
font-family: monospace;
overflow: auto;
white-space: pre;
}
body {
font-size: 100%;
}
</style>
</head>
<body>
<p>
Foo
</p>
<div class="wrap">123456789 123456789 123456789 123456789 123456789
123456789 123456789 123456789 234567890

int main()
{
printf("hello, world\n");
}
</div>
<p>
Bar
</p>
</body></html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top