Results 1 to 2 of 2

Thread: div height & padding issue: Chrome/IE difference

  1. #1
    Join Date
    Jun 2008
    Posts
    192
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Default div height & padding issue: Chrome/IE difference

    Hello,

    Please have a look at the two screen captures I've attached. One is take from Chrome, the other from IE. The one in Chrome looks correct. The one in IE does not.

    .Click image for larger version. 

Name:	chrome.jpg 
Views:	533 
Size:	27.3 KB 
ID:	5623Click image for larger version. 

Name:	ie.jpg 
Views:	591 
Size:	33.8 KB 
ID:	5624

    What you're looking at is a div with a light blue background inside a table cell. The table is the box with the red header and a single cell for the body. In Chrome, the blue div fits nicely into the table cell, but in IE, the top and bottom spill over the cell borders.

    Here's the HTML

    Code:
    <table cellspacing="0" cellpadding="0" border="0" id="SelectCourseTypeTable">
        <tr>
            <td id="SelectCourseTypeTableHeaderCell"><span id="SelectCourseTypeSpan">&nbsp;</span></td>
        </tr>
        <tr>
            <td id="SelectCourseTableCellBody">
                <div id="SelectCourseTypeDiv">
                    <input type="radio" id="PLARRadioButton" name="CourseType" value="PLAR" onclick="RadioButton_Click()" />Prior Learning Assessment (PLAR)
                    <br />
                    <br />
                    <br />
                    <input type="radio" id="SeqRadioButton" name="CourseType" value="Sequential" checked="checked" onclick="RadioButton_Click()" />Modular Course Delivery
                    <br />
                    <br />
                    <br />
                    <div id="OkButtonDiv">
                        <input id="OkButton" class="OkButton" type="button" value="OK" onclick="OkButton_Click()" />
                    </div>
                </div>
            </td>
        </tr>
    </table>
    Here's the CSS:

    Code:
    #SelectCourseTableCellBody
    {
        height: auto;
    }
    
    #SelectCourseTypeDiv
    {
        height: 100%;
        text-align: left;
        padding-top: 100px;
        padding-left: 30px;
        padding-right: 30px;
        padding-bottom: 100px;
        background-color: rgb(232, 238, 246);
    }
    
    #OkButtonDiv
    {
        width: 100%;
        text-align: center;
        height: 20%;
    }
    
    #OkButton
    {
        width: 80px;
        height: 100%;
        font-size: 16pt;
    }
    There's more CSS of course, but the above is the relevant portion.

    What I've noticed is that if I comment out the top and bottom padding on the blue div like so...

    Code:
    #SelectCourseTypeDiv
    {
        height: 100%;
        text-align: left;
        /*padding-top: 100px;*/
        padding-left: 30px;
        padding-right: 30px;
        /*padding-bottom: 100px;*/
        background-color: rgb(232, 238, 246);
    }
    ...it fixes the problem in IE, but then the contents of the div become aligned with the top with no spacing (for obvious reasons).

    I've tried working with this, adjusting this and that CSS setting, or this and that html setting (ex. adding <br/> before the first radio button), but nothing so far meets all my requirements (for example, keeping the positioning and size ratios when the browser resizes) or looks the same across browsers.

    It seems like there should be a simple fix for this. Obviously for IE, setting the height of the div to 100% does not include the padding (so any padding adding on top of the 100% height will go over 100%), but for Chrome, it does include the padding in the height. Isn't there a way to tell IE to include the padding in the height? So if I set the height of the div to 100% and the top and bottom padding to 100px, the actual height of the div should be 100% of its container (the table cell in this case) minus the top and bottom padding.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    box-sizing: border-box; might help http://blog.teamtreehouse.com/box-si...le-css-layouts

    But I would recommend you drop the table layout and recode using divs.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Replies: 2
    Last Post: 07-15-2011, 08:32 PM
  2. Resolved padding issue
    By mlegg in forum CSS
    Replies: 1
    Last Post: 07-01-2011, 01:17 AM
  3. table cell padding values for chrome
    By since in forum JavaScript
    Replies: 2
    Last Post: 05-24-2010, 12:26 PM
  4. Replies: 2
    Last Post: 06-01-2007, 05:49 AM
  5. 5 px height difference in IE/FF
    By snooper in forum CSS
    Replies: 10
    Last Post: 05-02-2007, 08:36 PM

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
  •