jQuery Mobile中的居中元素 [英] Centering elements in jQuery Mobile
本文介绍了jQuery Mobile中的居中元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery Mobile框架是否有一种使元素居中的方法,特别是按钮?看起来它默认情况下是将所有内容都左对齐,并且我找不到在框架内执行此操作的方法.
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似乎没有将元素居中的css类(我在其css中进行了搜索).
jQuery Mobile doesn't seem to have a css class to center elements (I searched through its css).
但是您可以编写自己的其他CSS.
But you can write your own additional css.
尝试创建自己的:
.center-button{
margin: 0 auto;
}
示例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;
}
示例HTML:
<div class="center-wrapper">
<div data-role="button">button text</div>
</div>
这篇关于jQuery Mobile中的居中元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文