0

I created a drop-down box with the following code:

var s = $('<select/>',{id:"subCategory"});

Would someone be able to tell me how I can centre-align this using CSS?

This is a bit more of my code:

JavaScript

var a = $('<h3/>',{id:"h3SubCategories", text:"Sub Categories"});
a.appendTo("#subCategories");

// add the subcategory drop-down box.               
s.appendTo("#subCategories");

HTML

<div id="subCategories">            
    <div id='loadingDiv1'>
            Please wait...  <img src="http://i.stack.imgur.com/FhHRx.gif" />
    </div> 
</div>

#loadingDiv1 is shown and hidden at various times.

Thank you.

4

1 回答 1

2

我认为应该这样做。

#subCategory
{
  text-align:center;
  margin:0 auto;
  display:block;
}

这是相同的工作演示

希望这可以帮助。

于 2013-10-18T10:01:33.447 回答