2

I am trying to move the background image [arrow] to the extreme right of the button, I need approx 10px or 15px padding from the right side of the input button like this: jsfiddle.net/44f61m5e/

HTML:

<input type="button" value="Add a new row" class="button_add" />

CSS:

input.button_add {
    height: 32px;
    padding-right: 36px;
    border: 1px solid #000;
    background: #ff9900 url(http://placehold.it/16x16) no-repeat right;   cursor: pointer;
}

Demo : http://jsfiddle.net/Tk68M/150/

Can anyone suggest the better way without adding an image tag like this: jsfiddle.net/44f61m5e/

Thanks in advance.

K K
  • 17,794
  • 4
  • 30
  • 39
Ismail Vittal
  • 1,077
  • 9
  • 12
  • 2
    possible duplicate of [Position a css background image x pixels from the right?](http://stackoverflow.com/questions/3197250/position-a-css-background-image-x-pixels-from-the-right) – Justinas Nov 24 '14 at 10:19
  • 1
    background-position: right 30px center; Worked for me :) @Justinas Thanks for routing me to the proper stackoverflow thread. – Ismail Vittal Nov 24 '14 at 10:24

3 Answers3

1

This one worked for me and solved my issue:

 background-position:right 10px center;
Ismail Vittal
  • 1,077
  • 9
  • 12
0

use background-position property like this-

background-position: 95% 30%;

demo

Rasel
  • 5,488
  • 3
  • 30
  • 39
0

It´s not possible use the background like this, you can´t set "15px from the right side".

Only way is to use another element as in your second fiddle. Or have the background image wider, the image has to include the arrow and right whitespace too. Than you can use background-position: right.

Of course, when you want to move the arrow a few pixels left/right, you need to edit this image. Better is to use button and the second element for the arrow.

pavel
  • 26,538
  • 10
  • 45
  • 61