2011-11-01 62 views
0

在我的网站,我使用jQuery Mobile的,我需要使用网格对齐按钮,在每个小区的中心:jQuery Mobile的:风格电网验证HTML5

| [BUTTON] | [BUTTON] | [BUTTON] | 

我的代码是

<div class="ui-grid-c" align="center"> 
    <div class="ui-block-a"> 
     [button code] 
    </div> 
    <div class="ui-block-b"> 
     [button code] 
    </div> 
    <div class="ui-block-c"> 
     [button code] 
    </div> 
</div> 

但是,如果我在div中使用align属性,我会收到HTML5验证错误。

所以我的问题是,我如何设置一个样式来获得图形结果?

+1

有没有像ALIGN = “中心” 的DIV。你可以使用text-align =“center” – defau1t

回答

1

我不知道,如果你想在他们旁边另一个或在彼此的顶部(但在中间)一致,但增加text-align:center;ui-grid-c DIV应该让自己在下面的div和将强制按钮(<input><button>)被集中,因为它们是内联元素。

Here's JSFiddle示例。

编辑
另外,如果你希望他们能在走,你会想float内的div并为它们指定宽度(33%应该是不错的,如果你只有三个)。看我的例子。

而这里的代码:

.ui-grid-c { 
    text-align:center; 
} 
.ui-grid-c > div { 
    width:33%; /*Remove this if you don't want them in a line*/ 
    float:left; /*Remove this if you don't want them in a line*/ 
} 
+0

完美,谢谢! –

+0

不客气! –

0
<div style="margin:0 auto;"> 
----Conent------ 
</div> 

这样可以在div的两侧产生利润空间。