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.

Select Input (drop down) text align issue

Discussion in 'CSS' started by happyharry, Feb 19, 2010.

  1. #1
    Ive got a select box (drop down), that has a set size, 10 pixels taller + longer an a default one. In firefox + ie the text inside is aligned top right. I want the text to be aligned vertically center. Chrome does this automatically.. if i use padding etc it fixes it in firefox etc but breaks it in chrome... this is an asthetic thing rather than function

    Thank you !!!!
     
    happyharry, Feb 19, 2010 IP
  2. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #2
    <jamie>Well there's your problem</jamie>

    As I JUST said in another thread:

    Attempting to change the alignment of content, formatting, or basically anything more than border and color is pretty much going to /FAIL/ cross browser. Form elements simply do not respond to padding, margin, height or width the same way across browsers with EVERY SINGLE ONE OF THEM having a different behavior. Get used to it.

    Though silly question, you want the text content of the element centered in the select, is there some reason you aren't using text-align?
     
    deathshadow, Feb 20, 2010 IP
  3. happyharry

    happyharry Peon

    Messages:
    93
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Text align doesnt seem to work :(
     
    happyharry, Feb 20, 2010 IP
  4. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #4
    if you set it on BOTH select and option, it will work in FF and Opera, in Chrome it will center the 'selected' part but will ignore it in the drop-down, while for IE and Safari it does absolutely nothing.

    As I said, what you are trying to do cannot be done cross-browser using HTML/CSS because the HTML/CSS specification doesn't actually SAY how CSS or styling is supposed to be applied to form elements.

    Royal PITA. I've seen people resort to using a javascript 'replacing' code to fake the appearance of a select to pull it off - which might be the only real way to do it; just be sure if you go that route you include the select as a scripting-off fallback.
     
    deathshadow, Feb 20, 2010 IP