Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flipped rendering for *-right and *-left #57

Open
morteza opened this issue Jan 21, 2015 · 11 comments
Open

Flipped rendering for *-right and *-left #57

morteza opened this issue Jan 21, 2015 · 11 comments

Comments

@morteza
Copy link
Owner

morteza commented Jan 21, 2015

Semantics for right and left are not changed in bootstrap-rtl theme, and you need to add a custom .flip classes to a .pull-right and .pull-left entity if it needs to be rendered from right to left (instead of left to right). It would be convenient to create additional css file (e.g. bootstrap-flipped.css) so this flipping process could be automated without the .flip class.

However, due to the consistency of meanings of the words, flipping would never happen to the .pull-right and .pull-left in bootstrap-rtl.css file.

@morteza morteza added this to the v3.3.2 milestone Jan 21, 2015
@LyoNick
Copy link
Contributor

LyoNick commented Jan 21, 2015

good idea

@asaf
Copy link

asaf commented May 5, 2015

Hey,
I have a web site that requires both support for RTL/LTR,
If possible, can anyone give some guides how to flip dynamically between the two ?

Thanks.

@afattahi54
Copy link

You can do it very easily. I do not know what is your server side language but the idea is simple. Always load bootstrap.css, if your site is in RTL mode, add bootstrap-rtl css

<link href="/styles/bootstrap.min.css" rel="stylesheet" type="text/css"  media="all" />
      <If the site is in RTL mode>
           <link href="/styles/bootstrap-rtl.min.css" rel="stylesheet"  type="text/css" media="all" />
     </endif>

@asaf
Copy link

asaf commented May 6, 2015

@afattahi54 So I guess the answer is, if rtl.css is loaded, I can't switch back to LTR, right?

@afattahi54
Copy link

Yes you can? If the page is reloaded from server you can only load bootstrap.css, if you want to switch page direction, with javascript you can remove the bootstrap-rtl.css with javascript as mentioned in http://stackoverflow.com/questions/24087152/remove-css-file-with-javascript

@AlexYudaev
Copy link

@asaf
this is my way.
Adding to html dir="rtl" or "ltr" and then check by js

    if(document.getElementsByTagName('html')[0].dir != "rtl"){
        document.write('<link href="bootstrap.min.css" rel="stylesheet">');
    } else {
        document.write('<link href="bootstrap-rtl.min.css" rel="stylesheet">');
    }

@afattahi54
Copy link

@AlexYudaev
I belive the bootstrap.min.css must always be loaded. OR the bootstrap-rtl should have bootstrap.css on top of it

@AlexYudaev
Copy link

@afattahi54
you right. sorry, in my projects i just include bootstrap to bootstrap-rtl.

@willi1s
Copy link

willi1s commented May 6, 2015

I use AngularJS, so use ng-if to pull in the relevant file:

<link rel="stylesheet" href="bower_components/bootstrap-rtl/dist/css/bootstrap-rtl.css" ng-if="getCurrentLanguage().rtl"/>

I also use an ng-class on the body to add an rtl class:

<body ng-class="{rtl:getCurrentLanguage().rtl}">

I then use css to set the text direction and override bootstrap classes rather than going around adding .flip mainually:

.rtl {
    direction: rtl;
}

.rtl .pull-right {
    float: left !important;
}

.rtl .pull-left {
    float: right !important;
}

.rtl .dropdown-menu-right {
    left:  0;
    right: auto;
}

.rtl .dropdown-menu-left {
    left:  auto;
    right: 0;
}

@asaf
Copy link

asaf commented May 6, 2015

Thanks guys, I just wanted to ensure that while the rtl css loaded there's no way to revert back to LTR,

@willi1s Nice trick with the ng-if, Shame on Ember.js not having anything that completes with param level directives.

Thanks!

@kirangottumukkala
Copy link

Though I agree this is dirty method, I am able to fix this issue with my asp.net MVC5 project with the help of Resource files. I added a resource setting with blank value inside default one and with value that is pointing to bootstrap-rtl.min.css. Then I added this into @Html.Raw which would print the css link tag either empty or tag.

Resource.resx
RtlStyleSheet : ""

Resource.ar.resx
RtlStyleSheet: <link rel='stylesheet' href='Content/bootstrap-rtl.min.css' />

Index.html

<head>
@Html.Raw(Resources.Resouce.RtlStyleSheet)
</head>

Hope this helps asp.net mvc guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants