Dzomlija 0 Posted October 24, 2019 Report Share Posted October 24, 2019 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... Quote Link to post Share on other sites
Ingolme 1,021 Posted October 24, 2019 Report Share Posted October 24, 2019 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. 1 Quote Link to post Share on other sites
Dzomlija 0 Posted October 24, 2019 Author Report Share Posted October 24, 2019 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 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.