admin管理员组

文章数量:1244318

I have 2 jQuery mobile buttons inside a fieldset and would like to change the font-size of one of the buttons. I have tried adding an inline style but that did not work.

I have also tried this but that did not work as-well:

.myButton
{
   word-wrap: break-word !important;
   white-space: normal !important;
}

This is what is happening: (only on the iPhone)

Because the screen size of the iPhone, the "Request Change" button is being cut-off.

Is there a way for me to change the font-size of the button text so that it shows the plete text without getting cut-off?


HTML:

<fieldset class="ui-grid-a">
    <div class="ui-block-a">
        <input data-mini="true" type="submit" value="Cancel"  name="Submitbutton" class="button button-link"/>
    </div>
    <div class="ui-block-b">
        <input data-mini="true" data-theme="b" type="submit" value="Request Change" name="Submitbutton" class="button button-link" /> 
    </div>
</fieldset>

I have tried:

  • jquery mobile button text auto line break
  • Change font size of a jQuery Mobile button at runtime

I have 2 jQuery mobile buttons inside a fieldset and would like to change the font-size of one of the buttons. I have tried adding an inline style but that did not work.

I have also tried this but that did not work as-well:

.myButton
{
   word-wrap: break-word !important;
   white-space: normal !important;
}

This is what is happening: (only on the iPhone)

Because the screen size of the iPhone, the "Request Change" button is being cut-off.

Is there a way for me to change the font-size of the button text so that it shows the plete text without getting cut-off?


HTML:

<fieldset class="ui-grid-a">
    <div class="ui-block-a">
        <input data-mini="true" type="submit" value="Cancel"  name="Submitbutton" class="button button-link"/>
    </div>
    <div class="ui-block-b">
        <input data-mini="true" data-theme="b" type="submit" value="Request Change" name="Submitbutton" class="button button-link" /> 
    </div>
</fieldset>

I have tried:

  • jquery mobile button text auto line break
  • Change font size of a jQuery Mobile button at runtime
Share Improve this question edited May 23, 2017 at 12:00 CommunityBot 11 silver badge asked Jul 26, 2012 at 15:10 Farhan AhmadFarhan Ahmad 5,1987 gold badges42 silver badges70 bronze badges 2
  • Have you tried using % for font-size values? – jzacharia Commented Jul 26, 2012 at 15:54
  • Yes I have tried that. No luck :( – Farhan Ahmad Commented Jul 26, 2012 at 16:16
Add a ment  | 

2 Answers 2

Reset to default 9

Play with the following to find what's best on the iPhone screen

.ui-btn-inner{
    text-overflow: initial; /* Get rid of the ellipsis */
    padding-left: 5px; /* Play with padding to make max use of available button width */
}
.ui-btn-text {
    font-size: 15px; /* Play with font size of the text */
}

Live Example:

  • http://jsfiddle/Pjvvx/ (Width)
  • http://jsfiddle/3DSGT/ (Height)

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');

I think you're looking to do something like this:

$('#hrefButton3').children().children().css('font-size','10px');

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>

Related:

  • resizing a BUTTON through CSS

本文标签: javascriptchange font size of button text in jQuery mobileStack Overflow