Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS CSS Sprites and RTL problem

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32074
    shazdeh
    Member

    To shift images sprites, we use background-position property and to change the position of the background on the element we again use background-position property. So on the RTL stylesheets it becomes impossible to use CSS Sprites, unless you know the exact width of the element (to push the image to the correct distance from top left).
    This is not an issue on LTR languages because the coordinate system works from top left.
    How can we solve this?

    #55090
    mixxmac
    Member

    Could you check if the browser is using LTR or RTL, and use different stylesheets based on that (e.g style_ltr.css or style_rtl.css)?

    #54989
    shazdeh
    Member

    That’s not the problem. I’m using WP which automatically includes rtl.css in RTL languages. The problem is that to define where to show the background and to define what part of the background image shown we use the same css property. Assume that you want to show the icon on the right hand side of your element. It’s easy with css:

    background-position: right center;

    Now think that you have an image sprite and you want to show that on the right hand side. How do you do it?

    #54750
    TheLeggett
    Member

    As far as I know, there is no way to set the coordinates to begin in the upper right corner using only CSS.

    However, if you have enough information about the dimensions of the different objects, you might be able to do something like assigning the parent container “position: relative”, and then using “position: absolute; top: 0; right: 0;” on a secondary inner element. If you give this extra element the width/height of the part of the sprite you want to use, you could then use background position.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.