jquery移动自定义按钮

时间:2012-11-06 16:07:51

标签: jquery-mobile

我正在尝试使用Jquery Mobile 1.2创建自定义按钮。我的按钮显示但使用现有的自定义圆角默认按钮。我需要按钮来显示这样的。 http://i.imgur.com/RFeeQ.png

http://i.imgur.com/MaQ2h.png

#homepage .my-button {
background-image: url('../images/icons/btn_panel.png') !important;
width:307px;
height:50px;
padding-top:0px auto;
}

#homepage  .ui-icon-about-icon {
border-radius:0px;
background-image: url('../images/icons/about_up.png');
background-color: rgba(0, 0, 0, 0);
width:36px;
height: 36px;
}

<div data-role="content" class="content">   
     <a href="about.html" data-transition="fade" data-role="button" data-icon="about-icon" data-iconshadow="false" class="my-button">About</a>
</div>

2 个答案:

答案 0 :(得分:1)

这是一个好的开始,只是继续操纵CSS ......我因为填充而调整了高度,但是可以随意玩耍...

 <style>
  #homepage .my-button {
    background-image: url("btn_panel.png");
    width:307px;
    height:75px;
    padding-top:0px auto;
  }

  #homepage .my-button .ui-btn-inner {
    padding-top: 25px;
  }

  #homepage .my-button .ui-btn-text {
    left: -80px;
  }

  .ui-icon-about-icon {
    border-radius:0px;
    background-image: url("logo36.png");
    background-color: rgba(0, 0, 0, 0);
    width:36px;
    height:36px;
  }
 </style>

删除圆角只需使用data-corners="false"

  <a href="about.html" data-transition="fade" data-role="button" data-icon="about-icon" data-iconshadow="false" data-corners="false" class="my-button">About</a>

我玩了一点并且得到了这个结果(我没有你的图像,但是使用了另一个......) screenshot

您还可以使用theme roller自定义CSS ...

答案 1 :(得分:0)

我会查看按钮的文档:

直播示例:

JS:

// For all buttons use something like this
$('.ui-btn').css('width','50%');

// For individual buttons use something like this
$('#theButton1').parent().css('width', '75%');

// Or this for HREF data-role buttons
$('#hrefButton4').css('width', '45%');

我认为这就是你要找的东西

// this changes the height for all buttons
$('.ui-btn-text').css('font-size','50px');

// This changes the height for a single element 
$('#hrefButton3').children().children().css('font-size','30px');

HTML:

<div data-role="page" id="home"> 
    <div data-role="content">
        <input type="button" id="theButton1" value="Press Me 1" />
        <input type="button" id="theButton2" value="Press Me 2" />
        <input type="button" id="theButton3" value="Press Me 3" />
        <input type="button" id="theButton4" value="Press Me 4" />
        <br />
        <a href="#" data-role="button" id="hrefButton1">HREF Me 1</a>
        <a href="#" data-role="button" id="hrefButton2">HREF Me 2</a>
        <a href="#" data-role="button" id="hrefButton3">HREF Me 3</a>
        <a href="#" data-role="button" id="hrefButton4">HREF Me 4</a>
    </div>
</div>

相关: