Jusify-end无法在VUE组件按钮上正常工作

发布于 2025-02-07 10:08:25 字数 977 浏览 0 评论 0原文

在我的vuejs组件中,我有一个带有提交按钮和取消按钮的表单。

我希望我的按钮正确对齐

代码

 <template slot="modal_actions">
                    <div class="flex items-center justify-end">
                        <close-overlay class="h-full" identifier="addNewScheduleModal">
                            <cs-button variant="blank">Cancel</cs-button>
                        </close-overlay>
                        <disables-submit-on-errors
                            :identifier="identifier"
                            @proceed="addNewSchedule"
                        >
                        <loading-button ref="submitBtnSave" size="normal">
                            Save & Close
                        </loading-button>
                        </disables-submit-on-errors>
                    </div>
                </template> 

是我当前

的 错误并对准它们。...

我正在使用tailwind-css

In my vuejs component, I have a form with submit button and a cancel button.

I want my buttons to align right

Following is my current code

 <template slot="modal_actions">
                    <div class="flex items-center justify-end">
                        <close-overlay class="h-full" identifier="addNewScheduleModal">
                            <cs-button variant="blank">Cancel</cs-button>
                        </close-overlay>
                        <disables-submit-on-errors
                            :identifier="identifier"
                            @proceed="addNewSchedule"
                        >
                        <loading-button ref="submitBtnSave" size="normal">
                            Save & Close
                        </loading-button>
                        </disables-submit-on-errors>
                    </div>
                </template> 

Even though I'm using justify-end class, still the button are aligned left...

I'm struggling to find what I'm doing wrong and align them right....

I'm using tailwind-css

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月朦胧 2025-02-14 10:08:25

假设您的取消按钮在左侧,并且加载按钮在取消按钮的右侧。

然后有两种方法,

  1. 您可以更改div之类的按钮的顺序:
 <template slot="modal_actions">
      <div class="flex items-center justify-end">
         <loading-button ref="submitBtnSave" size="normal">
             Save & Close 
         </loading-button>
         <disables-submit-on-errors
             :identifier="identifier"
             @proceed="addNewSchedule"
         >
         <close-overlay class="h-full" identifier="addNewScheduleModal">
               <cs-button variant="blank">Cancel</cs-button>
         </close-overlay>
                 .
                 .
   </div>
</template> 
  1. 您可以通过添加类flex将flex方向更改为ROW-RED-REVERSE - 逆转到Div。我在下面创建了一个类似的示例以理解目的。
<script src="https://cdn.tailwindcss.com"></script>
<div class="space-y-4">
<h3>Before</h3>
<div class="flex items-center justify-end h-96 w-full bg-red-200 space-x-10">
  <div class="h-56 w-1/3 bg-red-700">Cancel Button</div>
  <div class="h-56 w-1/3 bg-green-700">Loading Button</div>
</div>
<h3>After</h3>
<div class="flex flex-row-reverse items-center justify-end h-96 w-full bg-red-200 space-x-10">
  <div class="h-56 w-1/3 bg-red-700">Cancel Button</div>
  <div class="h-56 w-1/3 bg-green-700">Loading Button</div>
</div>
</div>

Assuming that your cancel button is at left and loading button is at right of cancel button.

Then there are two ways,

  1. you can change the order of buttons inside div like this:
 <template slot="modal_actions">
      <div class="flex items-center justify-end">
         <loading-button ref="submitBtnSave" size="normal">
             Save & Close 
         </loading-button>
         <disables-submit-on-errors
             :identifier="identifier"
             @proceed="addNewSchedule"
         >
         <close-overlay class="h-full" identifier="addNewScheduleModal">
               <cs-button variant="blank">Cancel</cs-button>
         </close-overlay>
                 .
                 .
   </div>
</template> 
  1. You can change the flex-direction to row-reverse by adding class flex-row-reverse to the div. I have created a similar example below for understanding purpose.

<script src="https://cdn.tailwindcss.com"></script>
<div class="space-y-4">
<h3>Before</h3>
<div class="flex items-center justify-end h-96 w-full bg-red-200 space-x-10">
  <div class="h-56 w-1/3 bg-red-700">Cancel Button</div>
  <div class="h-56 w-1/3 bg-green-700">Loading Button</div>
</div>
<h3>After</h3>
<div class="flex flex-row-reverse items-center justify-end h-96 w-full bg-red-200 space-x-10">
  <div class="h-56 w-1/3 bg-red-700">Cancel Button</div>
  <div class="h-56 w-1/3 bg-green-700">Loading Button</div>
</div>
</div>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文