1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

What is the best way to convert a large site using 'px' to use 'em'/'rem'

Discussion in 'HTML & Website Design' started by SoftLink, Jul 24, 2023.

  1. #1
    The subject pretty much says it.

    I've got a large software application using web technology with a large css file and some in element styles (yea I know).

    I guess I'm hoping for a formula or algorithm so I can write a little app that will convert all the px values to em or rem, based on px value.
    Also, what css properties should I exclude?
     
    SoftLink, Jul 24, 2023 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    Assume it was designed for normal users where 16px == 1rem.

    All you need to do then is divide by 16.

    Just beware that for users like myself, 1REM could be 20px, 24px, 32px or almost anything else. So for such users everything you declare in REM will be bigger.

    Which is the point. 16px doesn't scale, EM/REM does.

    But usually if some fool -- like PSD jockey artists under the delusion they're designers -- worked in PX it's because they don't know that PX doesn't scale and is inaccessible crap, and have only ever worked on computers where 1REM is always 16px. Divide by 16 using REM and you should be good to go in all but the rarest of corner cases, with everything scaling up or down as appropriate for the target audience of EM/REM.
     
    deathshadow, Aug 3, 2023 IP
  3. SoftLink

    SoftLink Active Member

    Messages:
    105
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Seeing you were the one who convinced me to convert I was hoping you'd respond:)

    I had kind of resolved to do exactly as you suggested so now I feel safe with it.
    Thanks for your help.
     
    SoftLink, Aug 4, 2023 IP