开发者

What's the css for setting a form select element's width and horizontal position?

开发者 https://www.devze.com 2023-01-13 13:11 出处:网络
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 bei

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消