How to take the current font size in css and increase

Asked

Viewed 534 times

1

Good morning, can someone help me give me a tip on how to get the current font size so I can enlarge it next? ps: I am using the Angularjs for the functions!

  • Can I ask why you want to increase the font? It would be a case of CSS queries?

  • I need to click the button and make it grow or decrease and can do it by css

  • Okay, I thought it would be case to increase/decrease depending on the screen size. Then CSS would be better. But in this case you need some Javascript, even if CSS makes changes with classes. Explain better then the HTML you have and how much you want it to grow etc...

  • There is a way to recognize font size via javascript?

  • Yes, with window.getComputedStyle(el).fontSize

  • How about the universal dial: What is the asterisk in "* {}" in CSS?

  • Thank you Sergio!

  • Marconi, I don’t understand the purpose of using this selector

  • * { font-size: 15px} will apply a source of 15 pixels to all tags @Gabrielsouza

  • @Gabrielsouza, if you give more details about your problem you will have better answers to your problem. Just as it is we’re still guessing what’s in the code.

  • 1

    @Sergio, thanks a lot for the help, I managed to achieve the goal using window.getComputedStyle(el). fontsize

  • @Gabrielsouza great! So mark as duplicate of another similar question to get more organized.

  • As others have said, the context of your doubt is unclear. But it may be the case to use relative units in your CSS, such as em or %. (CC @Sergio).

Show 8 more comments

1 answer

1


Hello,

There are several ways to do this, one of them is using the pseudo-selector focus. Below are two examples, one increasing with scale and another with font-size:

#bt-1:focus {
  transform: scale(1.5);
}
#bt-2:focus {
  font-size: 30px;
}
<p><button id="bt-1">Click para aumentar</button></p>
<p><button id="bt-2">Click para aumentar</button></p>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.