content overflow in display:inline-block; why and how? - html

Having this setup:
<div>
<label>...</label><br />
<!-- repeat several times -->
</div>
div {
display:inline-block;
overflow:auto;
max-height:3em; /* short enough to cause overflow */
/* or, in Chrome, this works too: */
padding:1ex;
}
will cause Chrome and Firefox to produce horizontal scrollbar:
JSFiddle
That Opera is Opera Presto, not Opera Blink. Too bad it's abandoned.
Anyway, why would this happen, and how would I get rid of the horizontal scrollbar if I need both max-height (thus auto overflow) and padding?
P.S. I'm using an XP machine (company restriction), if that matters.
P.S.#2 Further testing shows that disabling margin on <label>s puts out the horizontal scrollbar in Firefox, but the content will be crudely cut down to 3 characters length (the shortest label)cut down about 2 characters (the width of scrollbar).
Update #2:
In case people feel ambiguous:
Why would the container <div> shrink to the shortest length of its child (in this case, 3 chars) expand no more than the width of content in Chrome and Firefox, excluding scrollbar, letting long childs overflow?
There's no length info anywhere, so what's the logic here? I purposely added "Zero" so the first child is not the shortest one, but still got the same result.
Opera Presto seems to work as I expected, but that does not seem to be the de facto standard.
And how could I ask <div> to expand to as wide as it should, while still keeping a max-height and auto scroll?
Update #1:
The direct cause of scrollbar is of course content horizontally overflowed, so if I brutally apply overflow-x:hidden to <div>, the result will simply be this:
Update #3:
Thanks to #SergiyT., this turns out to be how Chrome and Firefox handles scrollbar, not the shortest child:
JSFiddle
I'm not sure if this is "right" (content has been overflow-ed before the longest child appear), but this seems like a dead end.

Perhaps it is how browsers work with scrollbars. It looks like opera (and maybe IE also) consider width/height without scrollbars but Firefox and Chrome take scrollbars into account. On your screenshot div width in Opera is bigger than in Firefox and Chrome.

This might help you
div.listbox {
overflow-x: hidden;
}

Try
div.listbox{
...
vertical-align: bottom;
}

Related

Internet Explorer resizing content after clicking/focusing on it

I've tried searching for this but found nothing. Might be using the wrong keywords. I made a gfycat of the problem.
https://gfycat.com/BrownHighErin
I have content, I click on it in IE, and things resize. Everything is flexbox display model, there are no anchor or button tags, it's just an image on the left and a table on the right wrapped in some divs. The project has a massive number of pages all using flexbox. This is the first I've seen this happen. I have been able to fix it with pointer-events: none but I'd rather not use that solution.
Another thing, the IE inspector does not show a change in the width of the element when this happens. It always shows the pixel width that the image should be, but not what is displaying.
Works in Edge, Chrome & Firefox
Without seeing your code, it's impossible to say for sure what the issue is. If it's only happening in IE, it's likely a compatibility issue. IE only has partial support for flexbox, as shown on CanIUse.com.
Some of the know issues with IE and flexbox include:
IE 11 requires a flex-basis property to be added
IE10 and IE11 containers may calculate any flexed childrens' sizes correctly if the container has a min-height but no height property set, and if the container uses display: flex and flex-direction: column
IE10 defaults flex to 0 0 auto, not 0 1 auto
See the CanIUse flexbox page for more details.

Height difference divs with `position: relative;` and smaller font

I asked this question about sub tag:
Using <sub> tag and preserve line-height
So now i use position: relative; and smaller font to "emulate" behaviour of subscript. But I have found that this solution is not pixel perfect. <div> with this emulated sub tag can have bigger height then <div> without this emulated sub tags, even when texts in each line line of divs are exactly the same. I observed this behaviour in Chrome and Firefox, here is the problem shown on live code:
http://jsfiddle.net/FRkQ6/
On my Chrome browser in Mac the output is:
Height of first div is: 163
Height of first div is: 162
This live code works on chrome on mac where both divs have the same lines with same text. On Firefox this demo does not work, because texts in lines are differently rendered. But the problem is similar to Chrome.
Can somebody explain me this behaviour? Is it some bug in browsers or intended behaviour? Can I fix that somehow with CSS (if i subtract height of top and bottom border, which is 2, height should be divisible by line-height, which is 20 in my demo, so I should never get height of 163)?
Even though the span is position:relative the browser is still (wrongly) considering its line height. Adding a line height of zero fixes it...
line-height: 0;
jsFiddle demo

FF/IE position:absolute bug

It seems Chrome is the only browser rendering my code the way I want.
If you notice my position:absolute is changing as the border size increases (in FF and IE) however is unaffected in chrome (which is exactly what I want).
Here is a demo Please try it in chrome/ie/ff to see the difference
The primary purpose of all of this black magic is simple, I need the .thumb:after to always be in the center of .thumb . If you know a better way let me know.
Edit: Fixed -- Checked in FF and Chrome (Don't have newer versions of IE)
http://jsfiddle.net/AyCKU/8/
Took out margin: 0 auto, just left it at using %'s for top and left and negative margins.
Basically: Used one of the methods for Vertical centering in CSS (Using 50% and negative margins) and applied it to both vertical and horizontal centering.
I messed around a little in Chrome + FF and noticed if you change:
.item .thumb:after
If you change the positioning to fixed and center it properly it will work in both browsers.
Give it a shot in IE and let me know if it works ..

Center Column not working in IE 8,9

I have a page with three columns. Left and right are floated and the middle is centered with margin auto 0 and overflow hidden to make it fluid. I have been stumbling for hours and can not figure this out :/
I've even tried changing to several doctypes.
I've whittled down the page to this:
http://dl.dropbox.com/u/1407764/www/stackoverflow/margin-0/details.html
Any ideas????
******************** Edit *******************
This problem only happens when the browser is wider than 1300 pixels or so.
Update... IE7 works fine, IE8 does not... but if you click compatibility mode, it works!!????
I've downloaded your page and wrapped col2 into a <div> with no max-width and left/right margins exceeding the widths of the respective floats. It worked in IE8 standards mode.

Weird IE6/IE layout bug

I've had quite a few problems with IE6 and our website.
http://www.sweetlets.com/w/solutions/click-stream/features/
At the very top the teaser boxes have scrollbars in IE6, but not IE7, IE8, FF or Chrome. Does anyone have an explanation for this?
Same effect in the footer with the 3 boxes in one row. Also scrollbars. Mathematically all fits into the row of 960px. I added up paddings, margins, borders and width and even kept some pixels left...
I simply don't know what is wrong. Any ideas?
Not sure if it'll fix it but I'd put a clear: both on #cf_content and remove overflow on the following:
#main
#content
#cf_content
#cf_content_teaser
You can set overflow:hidden; on the #cf_content_teaser to get rid of the scrollbars. Dunno if it's worth investigating further if that resolves the issue. You can apply the same to whatever other div it's happening on.