Repository navigation
Fix extra height under inline-block .text-truncate - #43414
Open
ngocanhnckh wants to merge 1 commit into
Open
ngocanhnckh wants to merge 1 commit into
ngocanhnckh wants to merge 1 commit into
Conversation
An element with `overflow: hidden` has its baseline at its bottom edge. An inline-block `.text-truncate` therefore sits on the baseline of the parent line. The line box adds space for the descenders below it. Set `vertical-align: top` in the `text-truncate` mixin. The extra space goes away. The property has no effect on block and flex items. Fixes twbs#36943
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
.text-truncateon aninline-blockelement adds about 6px of space below it. The line box keeps room for descenders. This happens at all widths.overflow: hiddenmoves the baseline of an inline-block to its bottom edge. The element sits on the parent baseline, and the space for descenders stays below it.vertical-align: topto thetext-truncatemixin. This is the fix that the issue suggests.<div class="text-truncate">has no gap before or after.<span class="d-inline-block text-truncate">is 32px high before and 26px after. This is the 2px border plus a 24px line. I checked 320, 375, 414, 768, 820, 1024 and 1440px, light and dark.d-block text-truncatechild inside a plain inline-block wrapper still has the gap. The wrapper causes that gap, not the helper.npm run css-lint,npm run css,npm run css-testandnpm run docs-buildpass.main.The red boxes in the before shots mark the broken part.
I maintain renderlint, an open-source CLI that renders pages in a headless browser and reports layout defects. I ran it on the text truncation and typography docs pages before and after this change. It reports no new problems. If it is useful, I can open a follow-up PR that runs it on the docs in CI.
Fixes #36943