aligning text of select

This is a discussion on aligning text of select within the CSS forums, part of the Development category; hi i want to align the text of select tag in the center by default the text of the select ...


Reply
 
LinkBack Thread Tools Display Modes
Old 30th November 2009, 09:19 PM   #1
Member
 
Join Date: Sep 2009
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
sudhakararaog is on a distinguished road
Expertise: Total Beginner
Experience: Basic / None
Default aligning text of select

hi

i want to align the text of select tag in the center by default the text of the select appears left. this is working in all browsers except for ie6 and 7 and safari

following is my code
#div select{
text-align: center;
}

how do i get ie and safari to align the text of select in the center as with the above code the text appears left for ie6 and 7 and safari

thanks
sudhakararaog is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Old 30th November 2009, 11:04 PM   #2
admin
 
saltedm8's Avatar
 
Join Date: Dec 2008
Location: Kent Uk
Posts: 1,464
Blog Entries: 5
Thanks: 13
Thanked 43 Times in 43 Posts
saltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond repute
Expertise: (X)HTML / CSS
Experience: Professional
Default

hmmm, I would have thorght that should work across all browsers

have you tried just using margin left instead or possibly padding ?

post a link or post the html and css so we can have a look
__________________
THePiNcH
saltedm8 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Old 30th November 2009, 11:19 PM   #3
Member
 
Join Date: Sep 2009
Posts: 108
Thanks: 0
Thanked 0 Times in 0 Posts
sudhakararaog is on a distinguished road
Expertise: Total Beginner
Experience: Basic / None
Default

thanks for replying following is my code

<div id="row1">
<form action="#">
<select>
<option>1</option>...
</select>
</form>
</div>

#row1{
float: left;
width: 186px;
height: auto;
margin: 0 0 0 0;
padding: 10px 0 5px 0;
text-align: right; // this is needed as the select needs to be right aligned
}

#row1 select{
width: 50px;
text-align: center;
}


if i use margin or padding then it will be an approximation however if text-align: center can work it will be accurate even if the text increases or decreases for all browsers.

thanks.
sudhakararaog is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Old 30th November 2009, 11:59 PM   #4
admin
 
saltedm8's Avatar
 
Join Date: Dec 2008
Location: Kent Uk
Posts: 1,464
Blog Entries: 5
Thanks: 13
Thanked 43 Times in 43 Posts
saltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond reputesaltedm8 has a reputation beyond repute
Expertise: (X)HTML / CSS
Experience: Professional
Default

Quote:
Originally Posted by sudhakararaog View Post
this is needed as the select needs to be right aligned
what is that about ?

basically what is happening is you are telling it to go right, but then moving it to the middle so each browser is 'guessing' to what you really what to do with it

its like me saying to you to turn right and go straight on at the same time if I were handing you directions.. it just cant be done

please tell me why you have done that as I would never see any reason for that

also, from what I can tell... this height: auto; and this margin: 0 0 0 0; are doing nothing at all, it looks like pointless code
__________________
THePiNcH
saltedm8 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!twitter
Reply With Quote
Reply

Tags
aligning, select

Thread Tools
Display Modes