# Fit text to parent element in ionic 2

**URL:** <https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491>\
**Category:** ionic-v3\
**Created:** [August 24, 2016, 7:22pm UTC](https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491 "2016-08-24T19:22:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamesdef](https://avatars.discourse-cdn.com/v4/letter/j/f17d59/32.png) [@jamesdef](https://forum.ionicframework.com/u/jamesdef)\
**Post date:** [August 24, 2016, 7:22pm UTC](https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491/1 "2016-08-24T19:22:58Z")

</div>

Hi,

I’m looking for a way to style a font size relative to its parent height (similar to the jquery plugin ‘Fittext’), but I’m looking for the best way to integrate this in my angular 2 project.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Yuzi](https://avatars.discourse-cdn.com/v4/letter/y/d26b3c/32.png) [@Yuzi](https://forum.ionicframework.com/u/Yuzi)\
**Post date:** [February 20, 2017, 4:55pm UTC](https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491/2 "2017-02-20T16:55:03Z")

</div>

Did you got it working?

---

<div class="post-metadata">

**Author:** ![nvirth](https://avatars.discourse-cdn.com/v4/letter/n/b2d939/32.png) [@nvirth](https://forum.ionicframework.com/u/nvirth)\
**Post date:** [February 15, 2018, 4:57pm UTC](https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491/3 "2018-02-15T16:57:58Z")

</div>

I’m also interested. Isn’t there an ionic recommendation for this?

---

<div class="post-metadata">

**Author:** ![anna\_liebt](https://avatars.discourse-cdn.com/v4/letter/a/bc8723/32.png) [@anna\_liebt](https://forum.ionicframework.com/u/anna_liebt)\
**Post date:** [February 15, 2018, 7:19pm UTC](https://forum.ionicframework.com/t/fit-text-to-parent-element-in-ionic-2/61491/4 "2018-02-15T19:19:00Z")

</div>

Hello,

if an element has a fixed value, then you can use css calc shown here [https://css-tricks.com/a-couple-of-use-cases-for-calc/](https://css-tricks.com/a-couple-of-use-cases-for-calc/)

As far as I know css calc can not retrieve the values of a css property or get it from an other element dynamic.

Angulars ngStyle let you point to a variable in .ts, where it can be calculated.

Maybe mediaquery can be used.

You can catch an html element and set its style like myElement.style.backgroundColor = “#D93600”; from ts or use addClass or related

If the text is fixed you can use svg with text as path and scale it it as any hmtl tag.

Overlay two elements and animate one with scale etc. with an js animation library.

Maybe on of the js to css librarys work

or…

Bset regards, anna-liebt
