Search code examples
htmlcssright-to-left

`float:left` and a rtl direction in a css stylesheet


how do I turn the float:left into a float:right when the page is viewed in right to left languages? (Same JSP file is used)


Solution

  • You can't just "turn" it, especially not with pure CSS.

    Some of your options are:

    1. Create two separate CSS style sheets (e.g. ltr.css and rtl.css) each with its own rules then load the proper file using server side code.
    2. When switching to rtl view, have JavaScript code that iterates over all relevant elements and changing their style - with jQuery it's going to be pretty simple to implement but also possible with plain JavaScript.