jquery mobile -5 个连续按钮

标签 jquery css jquery-mobile

谁能告诉我在 JQuery Mobile 中如何使按钮的大小适合屏幕分辨率,我的意思是,如果我在 Galaxy S2 中有 5 个按钮,我会在 1 行中看到它。但如果我使用其他屏幕较小的手机,它就会分布在两行上。

如何让按钮保持在 1 行? (并减小按钮/文本大小)在所有屏幕中? 我尝试这样做:

.ui-button{高度:10%}

但它不起作用!有任何想法吗?谢谢:)

<div class="center-wrapper" style="margin-bottom:10px float:left ">
      <a class="b" data-role="button" data-inline="true" style="margin: 1px;"> 6 <a/>   
      <a class="b" data-role="button" data-inline="true" style="margin: 1px;"> 7 <a/>
      <a class="b" data-role="button" data-inline="true" style="margin: 1px;"> 8 <a/>
      <a class="b" data-role="button" data-inline="true" style="margin: 1px;"> 9 <a/>
      <a class="b" data-role="button" data-inline="true" style="margin: 1px;"> 10 <a/>    
</div>

最佳答案

像这样的怎么样: DEMO FIDDLE

每个按钮都包含在一个 DIV 中,设置为以 float: left 内联方式显示,宽度为 20%(一行 5 个)。在我的示例中,当屏幕宽度小于 480 像素时,使用媒体查询来减小字体大小;您可以根据自己的喜好进行调整或选择不考虑字体大小。

<div data-role="content">
    <div id="fiveButtons" class="center-wrapper" style="margin-bottom:10px float:left "> 
        <div class="b"><a class="c"  data-role="button" data-inline="true" style="margin: 1px;" > 6 </a> </div>  
        <div class="b"><a class="c" data-role="button" data-inline="true" style="margin: 1px;" > 7 </a></div>
        <div class="b"><a class="c" data-role="button" data-inline="true" style="margin: 1px;" > 8 </a></div>
        <div class="b"><a class="c" data-role="button" data-inline="true" style="margin: 1px;" > 9 </a></div>
        <div class="b"><a class="c" data-role="button" data-inline="true" style="margin: 1px;" > 10 </a></div>    
</div>        


#fiveButtons .b{
    display: inline;
    float: left;
    width: 20%;
}
#fiveButtons .c{
    width: 92%;
}
#fiveButtons  .ui-btn-inner {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
}
@media all and (max-width: 480px){
     #fiveButtons  .ui-btn-inner { font-size: 12px }
}    

关于jquery mobile -5 个连续按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20316021/

相关文章:

javascript - 在 componentDidMount() 下调用 jQuery 函数会阻止 onChange 事件

css - div布局有问题,没有去他们应该去的地方

html - Rails 4 - 如何在保留 html 样式的同时在 Rails 中编写链接

html - 如何将一个DIV放在浏览器的中心

javascript - 检查互联网连接,然后在网页中的 JQuery/Javascript/Ajax 中更改图像

javascript - jquery 未在外部 js 文件中与 Rails 一起运行

javascript - 将事件绑定(bind)到尚未创建的元素 jquery

jquery - 在 fontawesome 中堆叠图标

javascript - 如何将 Radium 中一个组件中使用的常用 CSS 样式应用到另一个组件中?

css - 如何在 jQuery Mobile 输入中添加 bootstrap 之类的前缀?