1

I need some help setting a css button. My intention is having 3 images inside a button forming a background image, lets call pic1, pic2 and pic3. I set pic1 as left and pic3 as right making the borders, I want pic2 to repeat-x filling all remaining space in between, the problem is that pic2 will gladly overwrite pic3.

what I have so far:

button {
    background: url("images/btn_00.jpg") no-repeat scroll 0 0%, 
                url("images/btn_01.jpg") repeat-x scroll center center, 
                url("images/btn_02.jpg") no-repeat scroll right center transparent; 
}

Do what I want is possible? how, please?

petervaz
  • 13,685
  • 1
  • 15
  • 15

2 Answers2

1

Your styles are using CSS3 -- so be warned (if you did not already know) that this won't work in IE8 or lower.

The answer to your question lies in understanding the Stacking Order of Multiple Backgrounds -- you need to have pic 3 stacked on top of pic 2, which means it should be listed before pic 2. (This is counter-intuitive with respect to how z-index works to determine which elements paint over the others.)

Faust
  • 15,130
  • 9
  • 54
  • 111
  • That did the trick. Thanks for taking the time to properly reading the question, for the on spot anwser and for the reference link. – petervaz Dec 15 '11 at 13:57
0

Short answer: no. One Element can only have one backgroud.

Perhaps you can do it with three elements in a element like:

<div id="mybutton">
  <img src="leftimage.png" />
  <span class="mymiddleElement">MyText in the Button</span>
  <img src="rightimage.png" />
</div>

and set the backgroud of the .mymiddleElement with css

Matthias
  • 218
  • 1
  • 12