Results 1 to 7 of 7

Thread: Clipped Scrollbar and Border in Webkit

  1. #1
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default Clipped Scrollbar and Border in Webkit

    Part of the textarea scrollbar and border is cut off:

    Code:
    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="UTF-8">
        <title>Clipped Scrollbar and Border in Webkit</title>
        <style>
            textarea,
            iframe {
                display: block;
                width: 300px;
                margin: 0;
                padding: 0;
            }
            textarea {
                height: 200px;
                resize: none;
                outline: 0;
                border: solid red;
                border-width: 0 0 5px;
            }
            iframe {
                height: 0;
                border: 0;
            }
        </style>
    </head>
    
    <body>
        <textarea>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
            <p>Hello, world!</p>
        </textarea>
        <iframe srcdoc="<p>xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</p>"></iframe>
    </body>
    
    </html>
    DEMO

    Why does it happen? What's the fix?

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Rain Lover,

    The cause of your problem appears to be...
    Code:
    
    iframe {
        height:0;
        border:0;
     }
    
    If you don't want it behave oddly, why not just use this instead...
    Code:
    
    iframe {
        display:none;
     }
    

    coothead
    Last edited by coothead; 05-05-2014 at 10:36 AM.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I agree with coothead that it's the iframe and that styles used to conceal it are not working as intended in Chrome. This is easily seen if you add a paragraph with content between the textarea and the iframe. It works in Safari though, so it's not really a webkit issue. And I'm like 99% sure that Chrome isn't rendering this properly.

    As to what to do about it. Coothead's idea works. But giving an element display none tells the browser that it doesn't have to parse it fully, leave any space for it, nor load any content for or in it (like images, other pages). In this simple example there's no problem with any of that except that its layout width will be ignored, at 0 px height though, that shouldn't be an issue. But if you were to want to manipulate the iframe later via javascript, it would be safer to use other methods to conceal it. Positioning it absolute and -3000px top and left would work for that and/or giving it visibility hidden. Either or both of these will hide it. Using the visibility property only would not take it out of the layout flow of the page though. That could be a good thing or not, depending upon what, if anything you wanted to do with it later.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there John,

    Paul O'Brian, over at SitePoint suggests using "position:relative" as the ideal cure.

    I would, though, like to know our friend "Rain Lover's" reason for zeroing the width and height values.

    coothead

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That seems very good (position: relative) and given the current problem as it's set out, nearly ideal (if you're worried about legacy IE browsers, there could be problems, but then you wouldn't use srcdoc for iframe, which is still, as of IE 11, unsupported*). But it really does depend upon why you want the iframe there, and what if anything would be done with the iframe later. Position relative will maintain the layout space, such that it is, whereas position absolute, used as I suggested would not. If that matters one way or the other, let that guide the decision.


    *The srcdoc attribute shows up as an attribute of the iframe in the DOM view, so could be used in IE 11. But not as the document property of the 'page' in/'window' represented by the iframe.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by coothead View Post
    Hi there John,

    Paul O'Brian, over at SitePoint suggests using "position:relative" as the ideal cure.

    I would, though, like to know our friend "Rain Lover's" reason for zeroing the width and height values.

    coothead
    Thanks for the solution, coothead!
    I'm working on a small application in which the user can change the iframe height size -- even to 0. I'll show you the application and ask for your review and John's when I've finished it. Thanks again!

  7. #7
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by jscheuer1 View Post
    I agree with coothead that it's the iframe and that styles used to conceal it are not working as intended in Chrome. This is easily seen if you add a paragraph with content between the textarea and the iframe. It works in Safari though, so it's not really a webkit issue. And I'm like 99% sure that Chrome isn't rendering this properly.
    I don't have Safari as its Windows version seems to be a dead project for Apple company. But I can reproduce the same issue in Opera and that's why I called it a Webkit bug.
    Thanks very much for the answer, anyway!

Similar Threads

  1. Replies: 5
    Last Post: 06-30-2012, 01:12 AM
  2. Webkit Zoom Bug in Ultimate Fade-In Slideshow
    By nrz13 in forum Bug reports
    Replies: 2
    Last Post: 09-13-2010, 12:54 PM
  3. Replies: 6
    Last Post: 04-20-2009, 03:30 PM
  4. Style webkit resize handles?
    By jlizarraga in forum CSS
    Replies: 0
    Last Post: 03-14-2009, 05:11 AM
  5. [DHTML] Expanding Clipped Image
    By rdutton in forum Submit a DHTML or CSS code
    Replies: 1
    Last Post: 10-10-2007, 04:34 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •