Results 1 to 4 of 4

Thread: Config background image to fit the button

  1. #1
    Sencha User
    Join Date
    Jul 2010
    Posts
    104
    Answers
    1
    Vote Rating
    1
      0  

    Default Unanswered: Config background image to fit the button

    Hi,

    I have a push button and set its iconCls: 'icon-myimage'. I define in the css file the icon-myimage class as below:

    Code:
    .icon-myimage{background-image: url(../icons/myimage.png); background-size: cover; height:auto; width:auto; max-width:100%; max-height:100%}
    The image displays very small in the button. I see in the debug window
    Code:
    .x-btn-default-small-icon .x-btn-icon {
    
    
    
    • width: 16px;
    • height: 16px;
    • top: 0;
    • left: 0;
    • bottom: 0;
    • right: 0;
    }
    I don't know how these classes are added automatically to my icon. If I disable width & height (16px) in the debug window then the icon fills up the button.

    I'm sure there is a way to config the css or in extjs javascript. Can somebody show me how to fix this problem? Thank you!

    Regards,

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,415
    Answers
    3899
    Vote Rating
    1269
      0  

    Default

    Those classes are from the CSS that comes with Ext JS. Your classes need to come before or use the same classes as the default ones to override them.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,790
    Answers
    583
    Vote Rating
    390
      0  

    Default

    The button CSS is quite delicate, generally you'd just specify a background image and no-repeat for the icon.

    To set the icon size:

    http://docs.sencha.com/ext-js/4-1/#!...tton-cfg-scale

  4. #4
    Sencha User
    Join Date
    Jul 2010
    Posts
    104
    Answers
    1
    Vote Rating
    1
      0  

    Default

    Hi,

    I used the scale and it worked. Thank you !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •