Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between IE10 and Chrome calculating heights of inline-block elements

I have a slightly modified Bootstrap Dropdown to truncate text within the button element, however, there seems to be a difference in how the height of the button element is calculated.

This fiddle demonstrates what I did initially The key seems to be the CSS controlling the span element within the button.

button.btn span {
    min-width:91px;
    max-width:91px;
    overflow:hidden;
    white-space:nowrap;
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    display:inline-block;
}

Below are the browser metrics for IE and chrome for the height of the button element:

IE inline-block metricsChrome inline-block metrics

Replacing the inline-block style on the span with a float: left as demonstrated in this fiddle appears to correct the heights and works across both browsers.

button.btn span {
    min-width:91px;
    max-width:91px;
    overflow:hidden;
    white-space:nowrap;
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
    float: left;
}

IE float: left metrics

What is causing the difference in element height between Chrome and IE when using inline-block and which is doing it correctly?

Update: Firefox appears to do the same thing as IE here.

like image 200
DJG Avatar asked May 14 '13 08:05

DJG


People also ask

What is the difference between inline block and inline block elements?

Compared to display: inline , the major difference is that inline-block allows to set a width and height on the element. Also, with display: inline , top and bottom margins & paddings are not respected, and with display: inline-block they are.

What is the difference of the CSS display inline block property with the display inline property?

The display: inline-block Value Compared to display: inline , the major difference is that display: inline-block allows to set a width and height on the element. Also, with display: inline-block , the top and bottom margins/paddings are respected, but with display: inline they are not.

Can we set height for inline elements?

Inline element properties:The height and width of an inline element cannot be set in CSS. You cannot set the height and width of block-level elements in CSS. Inline elements flow left to right, meaning inline elements appear on the same line unless the line wraps or there's an explicit line break ( <br/> )

Which CSS property and value would you use so that you can change the height and width of an inline element?

The inline-size CSS property defines the horizontal or vertical size of an element's block, depending on its writing mode. It corresponds to either the width or the height property, depending on the value of writing-mode .


1 Answers

I think that you'll find your answers at this URL:

http://blog.mozilla.org/webdev/2009/02/20/cross-browser-inline-block/

Note: did you gave a try to display:table-cell?

like image 125
Cholesterol Avatar answered Nov 10 '22 01:11

Cholesterol