Jump to content
Dzomlija

Can is use Image Sprites to define DIV backgrounds?

Recommended Posts

The CSS Image Sprites reference has definitely helped me to simplify some of the UI aspects of a new personal website I'm designing, as I'm able to combine several images into one for various stages of display such as Normal, Hover and Mouse Down.

However, when it comes to the layout of some other UI elements, such as a modal "Dialog Box" that is opened when a button or link is clicked, I still have to use individual images to define the static or repeating images for the DIV backgrounds.

I have attached two files that demonstrate what I'm trying to accomplish. The first file ("dzomlija_dlg_sprites_demo.png") shows the various sprites I use to compile the results ("dzomlija_dlg_demo.png").

So my question is this: How do I compile all the relevant sprites into one singular image for use within the CSS definitions for my "Dialog Box".

Finding out the answer will solve a similar issue I have with the CSS definitions for MouseOver tooltips that I'm implementing...

dzomlija_dlg_sprites_demo.png

dzomlija_dlg_demo.png

Share this post


Link to post
Share on other sites

Sprites have limitations. For one, the container must be the same size in pixels as the sprite you're representing, otherwise other sprites on the same image are visible. Another limitation is that sprites cannot be repeating since background-repeat repeats the whole image file and not just a part of it.

In short, you can't style a flexible box using sprites.

On the other hand, you can use the border-image property in CSS to split an image into parts and use them to style a box.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you, Ingolme.

The answer you provided is precisely what I've been looking for, and will most definitely be of use to me.👍

Now, if I can do the same but have the "Top Row" of the border (Top Left corner, Top Middle and Top Right corner) be of a different height without stretching (as shown in my original post image, the "DLG HEADER BAR"), then it'll really make my day.👌

Have a great day.

P.S. Your reply has also lead me to finding and downloading  Firefox Developer Edition , which I'm exploring now.

Border Image Demo.zip

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...