Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

CSS Sprites For Repetitive Image

Featured Replies

Hi,

 

Anybody can tell me how to use css sprites for repetitive image means how to repeat middle image in css.

 

Thanks in advance.

Can you explain what you mean by "repeat middle image in css"?

 

Sprites are combined images, either vertically or horizontally, where you set the height of the container just for the part of the image that ypu want to show, then each part is revealed on hover, visited, active or focus by moving the background-image. Where do you want to repeat the middle image?

  • Author

Can you explain what you mean by "repeat middle image in css"?

 

Sprites are combined images, either vertically or horizontally, where you set the height of the container just for the part of the image that ypu want to show, then each part is revealed on hover, visited, active or focus by moving the background-image. Where do you want to repeat the middle image?

 

I want to repeat image by vertically.

 

It is 300X1 size image and div height is 400px, so i want to repeat that image(background-image) repeat through whole div using css sprites.

 

Can you please help me?

 

Thanks

Edited by Ketu

We need to see the whole page code and the sprite image you want to use to see how many links you have and how they fit into the div with height: 400px. Are you using ul and li tags for the links inside the div?

  • Author

I have attached html and sprite image.

 

So please check it and give me exact solution.

 

I want class .article_middle repeatable.

Edited by Ketu

  • Author

I have attached html and sprite image.

 

So please check it and give me exact solution.

 

I want class .article_middle repeatable.

index.html

post-24740-0-48146600-1293527236_thumb.png

  • Author

Is that enough?

 

No i want to use with css sprites

 

 

 

 

i think it's not possible :( simply use another image to repeat it that will be faster and easier.

  • Author

No its possible to repeat image.

 

Can anybody help me pleaseunsure.gif

 

 

 

It's not possible to repeat a specific area of a sprite.

 

For faster load time, and for the sake of actually achieving the desired effect, use another image, and use method provided by Lev in his post:

 

Is that enough?

 

To further explain why it doesn't work, it's like looking out your window, and wanting to see the same red car, repeating over and over, as far as you could see in either direction, but it is just a window, and no matter how hard you try, you will see a variety of cars parked outside.

 

Now imagine that each car is an image in a sprite, what you see outside is the sprite image, and the window is the div.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.