amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

`<amp-fit-text>` ignores CSS that affects text layout

Open sparhami opened this issue 7 years ago • 5 comments

Originally reported as: https://github.com/ampproject/amp-by-example/issues/1454

When you apply any CSS to <amp-fit-text> that affects the size (e.g. padding, border), the sizing is done without taking any of those properties into consideration.

As a workaround, you can apply the styles to a parent container of <amp-fit-text>, which will affect the the measuring element. This workaround does not work for line-height, since that is set on the measuring Element directly.

sparhami avatar Aug 13 '18 17:08 sparhami

This issue hasn't been updated in awhile. @aghassemi Do you have any updates?

ampprojectbot avatar Nov 28 '18 02:11 ampprojectbot

line-height is a hard-coded constant, const LINE_HEIGHT_EM_ = 1.15;. We could add an optional attribute to override the constant value. Happy to submit a PR for this ...

cpapazian avatar Jan 02 '19 19:01 cpapazian

@sparhami let's verify with amp-truncate-text and close if not an issue there?

aghassemi avatar Jun 19 '19 16:06 aghassemi

I would like to use amp-fit-text in an email and customize the line height, and I can't use amp-truncate-text because it is not available for email. Any chance we can make it possible to customize the line height as already suggested?

@caroqliu FYI

TomerAberbach avatar Jan 20 '21 16:01 TomerAberbach

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jul 19 '25 08:07 stale[bot]