button - 通过 CSS 调整按钮的大小

标签 button resize jquery-mobile

我使用 jquery mobile 来生成我的按钮,我在下面有一个 CSS 代码来更改它的设计,但是无论我在宽度和高度中输入什么值,按钮的大小都不会改变,但它相对依赖于标签的字体大小。如何更改此设置,以便无论标签的字体大小如何都可以更改按钮大小?

$("#ui-1").css({'position':'absolute','left':'27.0px','top':'51.0px','width':'120.0px','height':'30.0px',});
$("#ui-1 .ui-btn-text").css({'font-family':'"Calibri","Arial","Sans Serif"','font-size':'0.75em','color':'black','text-align':'left','wordwrap':'normal','text-shadow':'1px 1px 1px #FFFFFF'});

最佳答案

现场示例:

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>

关于button - 通过 CSS 调整按钮的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7303035/

相关文章:

css - 如何在浏览器调整大小时截断 div 或单元格中的文本

iOS 7 - 动态调整标签和 ScrollView 的高度

css - 我怎样才能停止 jQuery Mobile 将样式应用到我的特定表单元素

javascript - JQuery Mobile 重复的 Js/Js 在其他页面中不起作用

css - Rails `button_to` CSS 样式不起作用

xaml - 按钮 VisualState Focused 不起作用

javascript - Javascript按钮多个音频源

Java 上一个按钮循环

html - 流体容器,具有流体固定流体内部布局

javascript - 如何在 iPad Safari 浏览器的 HTML5 代码中使用 Javascript 以编程方式清除 session 和 cookie 值