X
Nhấn vào đây để đến phiên bản di động của trang web.

Diễn đàn trợ giúp

Override "important!" in source files with userChrome.css

Được đăng

Hello,

I'm trying to change the default text direction in the URL bar from right to left (in FF RTL locals).

Replacing

html|input.urlbar-input:-moz-locale-dir(rtl) {

 direction: ltr !important;
 text-align: right !important;

}

with

html|input.urlbar-input {

 direction: ltr !important;
 text-align: left !important;

}

in chrome\browser\content\browser\browser.css does change the direction.

However, I can not achieve that with userChrome.css. Is it possible to override the "important!" rule in the source file with userChrome.css?

Thank you.

Hello, I'm trying to change the default text direction in the URL bar from right to left (in FF RTL locals). Replacing html|input.urlbar-input:-moz-locale-dir(rtl) { direction: ltr !important; text-align: right !important; } with html|input.urlbar-input { direction: ltr !important; text-align: left !important; } in chrome\browser\content\browser\browser.css does change the direction. However, I can not achieve that with userChrome.css. Is it possible to override the "important!" rule in the source file with userChrome.css? Thank you.

Giải pháp được chọn

If you use the html namespace in a rule then you need to add the line that define this namespace at the top of the userChrome.css file as you can see in the browser.css file. Otherwise html|<element> can't be resolved to the proper namespace.

Actually, best is probably to add this rule like I posted above via a separate file this is imported in userChrome.css that has the proper @namespace line(s).

I used *|input.urlbar-input instead of html|input.urlbar-input to make this work for all namespaces to avoid having to add a HTML namespace line.

Đọc câu trả lời này trong ngữ cảnh 1

Chi tiết hệ thống bổ sung

Phần bổ trợ đã cài đặt

  • Shockwave Flash 32.0 r0

Ứng dụng

  • Chuỗi đại diện người dùng: Mozilla/5.0 (Windows NT 6.1; rv:64.0) Gecko/20100101 Firefox/64.0

Thông tin chi tiết

cor-el
  • Top 10 Contributor
  • Moderator
17468 giải pháp 157850 câu trả lời
Được đăng

Câu trả lời hữu ích

If you change the BIDI text direction via "Ctrl+Shift+X" then Firefox should remember this although I don't know whether this is website dependent.

Because there is likely JavaScript active to set the proper BIDI direction, you may not be able to override this in userChrome.css.

Did you try to place these rules above the @namespace line or place the code in a separate file via @import url("<file>"); and don't use the default @namespace line?

I tested with this code in a LTR locale and have the text aligned to the right, but can't use Ctrl+Shift+X

*|input.urlbar-input:-moz-locale-dir(ltr) {
 text-align: right !important;
}

Try this code:

*|input.urlbar-input:-moz-locale-dir(rtl) {
 text-align: left !important;
}
If you change the BIDI text direction via "Ctrl+Shift+X" then Firefox should remember this although I don't know whether this is website dependent. Because there is likely JavaScript active to set the proper BIDI direction, you may not be able to override this in userChrome.css. Did you try to place these rules above the @namespace line or place the code in a separate file via <b>@import url("<file>");</b> and don't use the default @namespace line? I tested with this code in a LTR locale and have the text aligned to the right, but can't use Ctrl+Shift+X <pre><nowiki>*|input.urlbar-input:-moz-locale-dir(ltr) { text-align: right !important; }</nowiki></pre> ---- Try this code: <pre><nowiki>*|input.urlbar-input:-moz-locale-dir(rtl) { text-align: left !important; }</nowiki></pre>

Người tạo câu hỏi

Hello cor-el,

Thanks for testing and replying. I appreciate it.

I actually did not use the @namespace line at all. https://www.userchrome.org/adding-style-recipes-userchrome-css.html

I'm not quite sure if you were somehow able to override the source file with userChrome.css.

Regarding "Ctrl+Shift+X": you're right. With the following code it does work.

html|input.urlbar-input {

 direction: ltr !important;
 text-align: left !important;

}

html|input.urlbar-input[dir=rtl] {

 text-align: right !important;

}

Hello cor-el, Thanks for testing and replying. I appreciate it. I actually did not use the @namespace line at all. https://www.userchrome.org/adding-style-recipes-userchrome-css.html I'm not quite sure if you were somehow able to override the source file with userChrome.css. Regarding "Ctrl+Shift+X": you're right. With the following code it does work. html|input.urlbar-input { direction: ltr !important; text-align: left !important; } html|input.urlbar-input[dir=rtl] { text-align: right !important; }
cor-el
  • Top 10 Contributor
  • Moderator
17468 giải pháp 157850 câu trả lời
Được đăng

Giải pháp được chọn

If you use the html namespace in a rule then you need to add the line that define this namespace at the top of the userChrome.css file as you can see in the browser.css file. Otherwise html|<element> can't be resolved to the proper namespace.

Actually, best is probably to add this rule like I posted above via a separate file this is imported in userChrome.css that has the proper @namespace line(s).

I used *|input.urlbar-input instead of html|input.urlbar-input to make this work for all namespaces to avoid having to add a HTML namespace line.

If you use the html namespace in a rule then you need to add the line that define this namespace at the top of the userChrome.css file as you can see in the browser.css file. Otherwise html|<element> can't be resolved to the proper namespace. *https://dxr.mozilla.org/mozilla-release/source/browser/base/content/browser.css *@namespace html url("http://www.w3.org/1999/xhtml"); Actually, best is probably to add this rule like I posted above via a separate file this is imported in userChrome.css that has the proper @namespace line(s). I used <b>*|input.urlbar-input</b> instead of <b>html|input.urlbar-input</b> to make this work for all namespaces to avoid having to add a HTML namespace line.

Người tạo câu hỏi

Hello cor-el,

Great! Thank you very much.

Your code indeed overrides the source file.

  • |input.urlbar-input { direction: ltr !important; text-align: left !important; }
  • |input.urlbar-input[dir=rtl] { text-align: right !important; }

Best regards.

Hello cor-el, Great! Thank you very much. Your code indeed overrides the source file. *|input.urlbar-input { direction: ltr !important; text-align: left !important; } *|input.urlbar-input[dir=rtl] { text-align: right !important; } Best regards.