width in em !important doesn't work

Discussion in 'CSS' started by Abh, Jun 10, 2010.

  1. #1
    Hi.
    I have this width property.
    width: 1px !important; - works,
    width: 1em !important; - doesn't work.
    How come?
     
    Abh, Jun 10, 2010 IP
  2. pmek

    pmek Guest

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1 em is essentially 1%, if you wanted to replicate 1px in ems you would need to use a conversion chart - http://pxtoem.com/

    Hope this helps.
     
    pmek, Jun 11, 2010 IP
  3. Abh

    Abh Active Member

    Messages:
    162
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks for the answer, the problem was that the button was taking the with in pixels, but not in em. Somehow, that changed over night, no idea why. Now it works.
     
    Abh, Jun 11, 2010 IP
  4. pmek

    pmek Guest

    Messages:
    101
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Glad it works now. I was trying to say that 1em doesn't necessarily equal 1px. 1em will be relative to any other width attribute that may have cascaded onto your object
     
    pmek, Jun 11, 2010 IP
  5. johagulo

    johagulo Peon

    Messages:
    879
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Do you mean that it only does not work in ie6?
     
    johagulo, Jun 12, 2010 IP
  6. Abh

    Abh Active Member

    Messages:
    162
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #6
    No, i was testing live in firefox with firebug. That's how i knew px work and em don't. But the next day i tried again and it worked, i don't know why.
     
    Abh, Jun 12, 2010 IP
  7. drhowarddrfine

    drhowarddrfine Peon

    Messages:
    5,428
    Likes Received:
    95
    Best Answers:
    7
    Trophy Points:
    0
    #7
    'em' is relative to the current font setting. If you never set a font size, it may appear not to work.
     
    drhowarddrfine, Jun 12, 2010 IP
  8. Abh

    Abh Active Member

    Messages:
    162
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    60
    #8
    Maybe that was the problem.
     
    Abh, Jun 12, 2010 IP