Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8989509
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:16:40+00:00 2026-06-15T22:16:40+00:00

The buttons I’m creating for a UI consist of an icon plus some text,

  • 0

The buttons I’m creating for a UI consist of an icon plus some text, thus:

  [ <icon> Some Text ]

I’m using jQuery to create the button, with HTML like this:

<button class="myButton" type="button"/>

and JavaScript like this:

$('.myButton').button({
                    label: "Some Text",
                    icons: {
                        primary: "icon-custom",
                    }
                })
                .css({ width: '85px' });

The design team have specified requirements for how it should look, so I need an to have an 85px wide button (I’ve managed that bit) with a 5 pixel gap between the icon and text, then center the icon+text pair within the button.

Is this possible, and if so, how? I’ve not been able to figure it out.

It seems that the default is to left-align the icon on the button, then center the text in what’s left, but this doesn’t look very good.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:16:42+00:00Added an answer on June 15, 2026 at 10:16 pm

    Not very elegant, but should take care of your requirements.

    $('.myButton').button({
        label: '<span class="ui-button-icon-primary ui-icon icon-custom"></span>text',
    }).css({
        width: 85
    }).find('.ui-icon').css({
        display:'inline-block',
        position:'relative',
        top:4, //top varies depending on button height / font-size, adapt as needed
        marginRight:5
    });
    

    Fiddle

    This way, the icon is part of the centered text span. You just have to compensate the vertical align.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some dynamic buttons that look like this: <input type=button name=button id=button value=Click
I dynamically create buttons on a form and use the button text as ids
I have jquery buttons in my website,but some of these buttons doesnt have to
I have three radio buttons and 17 checkboxes. I would like the radio button
I have radio buttons in HTML like this: <td> <input id=radio1 type=radio name=correctAnswer value=1>1</input>
how to add icon buttons to jqgrid rows like shown in this demo? demo
I have two aspx buttons on two separate Jquery tab panels. I'd like to
My buttons are input type=button, id field set, and no text in between the
Buttons on my PhoneGap app using jQuery Mobile respond only after a few seconds
Some 'buttons' (divs with background images) on my webpage have shadow effects in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.