#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0

    How to know whether there is overflow in CSS


    Is there any way to find the overflow in CSS?

    I have two table using two different style.
    1. Header text
    2.Data



    I have scenario where size of table which has data may increase or decrease based upon resultset.
    I am using "overflow:auto",so that vertical bar will appear when data is huge in table,so that user can see all the records.

    This creates a problem in alignment of header and databody when there is no scroll bar.As width of databody moves with a little (width=scrollbar) to the right and mismatch with the header

    If scrollbar appears alignement is OK between header and content as scrollbar appears sidewise with content.

    Try running the exmple mentioned below for both option

    1.Without scrollbar

    <html>
    <head>
    <title>Untitled Document</title>
    <style type="text/css">
    div.head
    {
    background-color: #FFFFCC;
    border: 1px solid #000000;
    position: absolute;
    height: 25px;
    width: 385px;
    left: 50px;
    top: 22px;
    }
    div.scroll {
    background-color: #FFFFCC;
    border: 1px solid #000000;
    overflow-y: auto;
    position: absolute;
    height: 100px;
    width: 400px;
    left: 50px;
    top: 50px;
    }

    </style>
    </head>
    <body>
    <div class="head">
    <table width="100%" border="1" cellspacing="0" cellpadding="2">
    <tr>
    <td>Header1</td>
    <td>Header2</td>
    </tr>
    </table>

    </table>
    </div>
    <div class="scroll">
    <table width="100%" border="1" cellspacing="0" cellpadding="2">
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    </table>
    </div>
    </body>
    </html>


    2. With Scroll bar

    <html>
    <head>
    <title>Untitled Document</title>
    <style type="text/css">
    div.head
    {
    background-color: #FFFFCC;
    border: 1px solid #000000;
    position: absolute;
    height: 25px;
    width: 385px;
    left: 50px;
    top: 22px;
    }
    div.scroll {
    background-color: #FFFFCC;
    border: 1px solid #000000;
    overflow-y: auto;
    position: absolute;
    height: 100px;
    width: 400px;
    left: 50px;
    top: 50px;
    }
    </style>
    </head>
    <body>
    <div class="head">
    <table width="100%" border="1" cellspacing="0" cellpadding="2">
    <tr>
    <td>Header1</td>
    <td>Header2</td>
    </tr>
    </table>
    </table>
    </div>
    <div class="scroll">
    <table width="100%" border="1" cellspacing="0" cellpadding="2">
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    <tr>
    <td>content</td>
    <td>content</td>
    </tr>
    </table>
    </div>
    </body>
    </html>


    How can I rectify the same any suggestion.
  2. #2
  3. Senior Polecat
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Jersey (the original version)
    Posts
    210
    Rep Power
    11
    you could always turn overflow to scroll regardless of whether its needed or not.
    Quidquid latine dictum sit, altum viditur.

    http://www.XSet.co.uk
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    2
    Rep Power
    0
    My requirement is that I should show scroll bar when more data is available.

    If I use scroll I will be getting scrollbar with disabled option if data fits in the window.
  6. #4
  7. Senior Polecat
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2003
    Location
    Jersey (the original version)
    Posts
    210
    Rep Power
    11
    yeah but it solves your alignment problem!

    the only other thing I can think of is testing against the editable width of the div with javascript but that would have to be DOM scripted - i don't think there are global functions to do this.
    Quidquid latine dictum sit, altum viditur.

    http://www.XSet.co.uk

IMN logo majestic logo threadwatch logo seochat tools logo