css 引导浮动标签在方向为rtl时滑动到中心

mwg9r5ms  于 2023-03-20  发布在  其他
关注(0)|答案(1)|浏览(145)

我尝试使用bootstrap v5. 2显示希伯来语的浮动标签。问题是当我将方向更改为rtl时,当单击输入框时,标签会向中间滑动。
我的代码:

  1. <div class="form-floating mb-3" dir="rtl">
  2. <input class="form-control" id="title" placeholder="כותרת"></input>
  3. <label for="title">כותרת</label>
  4. </div>

You can see that the text moves to the center and does not stay adjacent to the right
我试图改变方向回到ltr只在标签,它的工作,但它不好看希伯来语(坚持左侧的方块).

taor4pac

taor4pac1#

添加一个自定义类并使用以下css代码:

  1. <style>
  2. .form-floating.custom-class>label {
  3. top: 0;
  4. right: 0;
  5. transform-origin: 100% 0;
  6. transition: opacity .1s ease-in-out,transform .1s ease-in-out;
  7. }
  8. .form-floating.custom-class>.form-control-plaintext~label, .form-floating.custom-class>.form-control:focus~label, .form-floating>.form-control:not(:placeholder-shown)~label, .form-floating>.form-select~label {
  9. opacity: .65;
  10. transform: scale(.85) translateY(-0.5rem) translateX(-0.15rem);
  11. }
  12. </style>
  13. <div class="form-floating mb-3 custom-class" dir="rtl">
  14. <input class="form-control" id="title" placeholder="כותרת"></input>
  15. <label for="title">כותרת</label>
  16. </div>
展开查看全部

相关问题