views:

45

answers:

1

I have a the following html code:

<div class="panel">Some Text Here</div>

With the following css attached

.panel{
    display:inline-block;
    height:100%;
    border:1px solid black;
}

Because the panel has a border it's causing the vertical scrollbar to appear, is there a way to make the CSS to recognize 100% to include the paddings, margins and border?

+1  A: 

Well, if you're targeting CSS3 you can use the box-sizing property

Of course, only newer browser support it, and even then they don't support it directly (yet), so you have to use the browser specific version (e.g. -moz-box-sizing)

.panel{
    display:inline-block;
    height:100%;
    border:1px solid black;

    box-sizing: border-box;         // IE8, Opera
    -moz-box-sizing: border-box;    // Firefox
    -webkit-box-sizing: border-box; // Chrome
}
Daniel LeCheminant
IE8 and Opera support `box-sizing`; you don't need `-ms-box-sizing` (that's what IE8 *would* have required, but MS decided to support unprefixed CSS3 properties when the relevant CSS3 module had reached Candidate Recommendation status or later, which `box-sizing`'s CSS3UI module has been at for ages).
bobince
IE8 isn't recognizing neither the inline-block nor the box-sizing... stupid explorer
William Calleja