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

RTL alignment problems: navbar-nav and navbar-brand #40671

Closed
ibleaman opened this issue Jul 26, 2024 · 4 comments
Closed

RTL alignment problems: navbar-nav and navbar-brand #40671

ibleaman opened this issue Jul 26, 2024 · 4 comments

Comments

@ibleaman
Copy link

I came across some alignment problems when adding a navbar to a multilingual website, where some of the pages have dir="rtl" specified in the root. Here are minimal examples:

Bootstrap 5.3.3 defines .ms-auto (and other .ms- values) based on margin-left. Also, .navbar-brand is defined with a margin-right property.

@TommasoAllegretti
Copy link
Contributor

Hi @ibleaman, from my understanding of what is explained in Bootstrap's documentation, if you want to enable RTL in Bootstrap-powered pages you need to include the RTL version of the CSS.

I have tried replacing the stylesheet link in the fiddle you shared with the RTL version and the result seems to be the same as the fixed version of the fiddle.

Here's the link tag:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.rtl.min.css" integrity="sha384-dpuaG1suU0eT09tx5plTaGMLBsfDLzUCCUXOY2j/LSvXYuG6Bqs43ALlhIqAJVRb" crossorigin="anonymous">

Hope I was of any help!

@ibleaman
Copy link
Author

@TommasoAllegretti Thank you for your quick response! Yes, I did overlook that step on the RTL documentation page.

Using the RTL version of Bootstrap fixes the problem in my jsfiddle link 2. However, it creates the same alignment problem if you use it in link 1, because .ms-auto is now defined as:

.ms-auto {
  margin-right: auto !important;
}

So: Is there no way to use a single Bootstrap 5 CSS file on a multilingual website, whether the original version or the RTL version, so that it works across all pages regardless of their direction? The documentation on spacing suggests that this is exactly what .ms- is supposed to accomplish:

s - (start) for classes that set margin-left or padding-left in LTR, margin-right or padding-right in RTL

The RTL documentation page also suggests that start/end are what's used in the CSS, not left/right. But both the original and the RTL versions of Bootstrap 5 still use left and right here.

I thought this was supposed to be an improvement over Bootstrap 4, which used ml instead of ms.

@TommasoAllegretti
Copy link
Contributor

I am not sure what the evolution of Bootstrap regarding this feature is, but according to "LTR and RTL at the same time", the solution to your problem should be RTLCSS String Maps.
I am not aware of your project's details but I hope that can be helpful in solving your issue.

@ibleaman
Copy link
Author

I'm closing this issue, as importing the RTL version of Bootstrap 5 is good enough for my use case.

Thanks again @TommasoAllegretti !

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

No branches or pull requests

3 participants
@ibleaman @TommasoAllegretti and others