tags:

views:

16

answers:

1

I am not able to figure out why this does happen. On all non-webkit browsers I tested the code below with (IE8, FFx 3.x, Opera 10.x) there is no scrollbar on the <pre> area. For both Chrome and Safari vertical scrollbar appears.

Of course I do not want it to appear.

The code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB" dir="ltr"> 
    <head>
        <style type="text/css" media="screen,projection">
body {
    color: black;
    font-family: Verdana, sans-serif;
    font-size: 90%;
}

#container {
    font-size: 9pt;
}

#container-content {
    color: black;
    line-height: 1.5em;
}

pre {
    background-color: #F9F9F9;
    border: 1px dashed #2F6FAB;
    color: black;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    line-height: 1.1em;
    overflow: auto;
    padding: 15px 20px;
    width: 150px;
}
        </style>
    </head>
    <body>
        <div id="container">
            <div id="container-content">
                <pre>line 1
line 2
and this is a very long like it is, and this is a very long like it is
line 4</pre>
            </div>
        </div>
    </body>
</html>

Note that this is a code snippet from a large project. All unrelated code is stripped out.

Removing line-height or making it >= 1.3em solves the problem but I want it to be 1.1em.

A: 

If you change the overflow property to the default (visible) or remove it, the scroll bar disappears. See: http://www.w3schools.com/css/pr_pos_overflow.asp

Ivo
This doesn't solve the issue. The text then goes out of the area of `<pre>` and doesn't look good. I've updated the code so you can change the value of `overflow` and see what I mean. I want to have a horizontal scrollbar within the `<pre>` for situations when I have a very long line.
Michal M
I think I see what you mean. Depending on your needs, you can use separate overflow properties for width and height, e.g. `overflow-x: auto;`, `overflow-y: hidden;`. This may be enough to make it look like what you want.
Ivo
I think it's a WebKit bug and your suggestion seems to solve the problem.
Michal M