在 jQuery Mobile 中居中元素 [英] Centering elements in jQuery Mobile
问题描述
jQuery Mobile 框架是否具有居中元素(特别是按钮)的方法?看起来它默认为左对齐所有内容,我找不到方法(在框架内)来做到这一点.
jQuery Mobile 似乎没有将元素居中的 css 类(我搜索了它的 css).
但是您可以编写自己的附加 css.
尝试创建自己的:
.center-button{边距:0 自动;}
示例 HTML:
看看会发生什么.您可能需要在环绕标签中将 text-align 设置为居中,这样可能会更好:
.center-wrapper{文本对齐:居中;}.center-wrapper * {边距:0 自动;}
示例 HTML:
<div data-role="button">按钮文本</div>
Does the jQuery Mobile framework have a way of centering elements, specifically buttons? It looks like it defaults to left-aligning everything and I can't find a way (within the framework) to do this.
jQuery Mobile doesn't seem to have a css class to center elements (I searched through its css).
But you can write your own additional css.
Try creating your own:
.center-button{
margin: 0 auto;
}
example HTML:
<div data-role="button" class="center-button">button text</div>
and see what happens. You might need to set text-align to center in the wrapping tag, so this might work better:
.center-wrapper{
text-align: center;
}
.center-wrapper * {
margin: 0 auto;
}
example HTML:
<div class="center-wrapper">
<div data-role="button">button text</div>
</div>
这篇关于在 jQuery Mobile 中居中元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!