CSS: Why is vertical-align: baseline stop working on Firefox when using overflow: hidden?

You can reproduce this by running this test case. The results are shown in the screenshot below. The issue is that on Firefox, when adding a overflow: hidden on the "block" (with grey background in the screenshot), the block stop being aligned as I'd like it to be: instead of the baseline of the text in the block being align to the the baseline of the parent box, it is as if the bottom of the block was aligned on the baseline of the parent box. As you can see in the screenshot, this doesn't happen with Chrome.

  1. Is this a Firefox bug?
  2. How to get the expected result on Firefox (baseline alignment with overflow: hidden)?

Screenshot

Note: Using vertical-align: middle on "block" doesn't cut it, as what I really want is baseline alignment. You can see more clearly that vertical-align: middle doesn't do baseline alignment by setting padding: 1em 0 .1em 0 (more padding at the top of the box), which give you:

With vertical-align: middle

13
задан Community 8 February 2017 в 14:31
поделиться