Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Apply font-size to only certain child elements

I have a project (a label maker) where I need to define a font-size and then apply in percentage the desired size to text elements.

This is working as expected but when I set font-size to the parent div (containing text, images, barcodes...), all the images get an offset of the font-size in pixels I set.

Since I will generate a PDF, the font-size of my text is stored in my db as an int and will be used as pt (point type). To achieve this, I set my font-size of the parent div to its height and set the font-size of my child elements as a percentage.

Basically I am doing this :

<div id='template' style="font-size: (labelHeight) + px">
    <div id='text' style="font-size: {{100*(field.fontSize*0.352778)/field.template.format.height }}%">
        <p>My text</p>
    </div>
    <div>
        <img id='myImage'>
    </div>
</div>

This is a simplification of my code (the syntax is not correct here but it is just to show you how it works).

I store my field.template.format.height in mm and my fontSize as an int. The 0.352778 value comes from the fact that 1pt = 0.352778mm.

Basically I want my fontSize of my template div to apply only to text elements.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The font-size property specifies the size of the text. If other elements inside the template div are affected by it, is it possible that their size/padding/margin is specified using em units, which are proportional to the font size. I'd suggest using rem units instead because they are proportional to the global font size and therefore unaffected by the changes of the template div's font size.

about 4 years ago · Juan Pablo Isaza Report

0

if the parent div has a font size and it child will inherit it. to fix this problem you should specify it one by one

For example <p style="style ETC"></p>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!