What's the css for setting a form select element's width and horizontal position?
Should width be开发者_StackOverflow treated instead with an html attribute?
I know about left and right margin for setting horizontal position, but the validation messages from my javascript are being messed up when using
margenleft{
margin-left:120px;
}
on a different resolution, how can I do this relatively? I want the select elements to be centrally placed.
If you change the select
to display: block, you can centre and set its width with the following CSS:
select {
/* Set as display block and auto left/right margins to centre */
display: block;
margin: 0 auto;
/* Set select's width */
width: 200px;
}
And for your viewing pleasure, an example.
精彩评论