css 如何用顺风元件的元件做多模态

wkyowqbh  于 2023-07-01  发布在  其他
关注(0)|答案(1)|浏览(115)

我想做身份验证模态时,我登录模态,并点击“创建帐户”在此模态我需要隐藏登录模态,并打开注册模态标准过程应该做的。我使用顺风元素的模态,我该怎么做?

fkaflof6

fkaflof61#

考虑在“创建帐户”按钮元素周围使用 Package 器元素。这意味着你可以让一个元素关闭当前的modal,另一个元素显示新的modal:

<link
  rel="stylesheet"
  href="https://cdn.jsdelivr.net/npm/tw-elements/dist/css/tw-elements.min.css" />
<script src="https://cdn.tailwindcss.com/3.3.2"></script>

<button type="button" data-te-toggle="modal" data-te-target="#login" class="rounded px-2 pb-2 pt-2.5 text-primary">
  Login
</button>

<div
  data-te-modal-init
  class="fixed z-[1055] top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 z-10 hidden"
  id="login"
  tabindex="-1"
  aria-hidden="true"
>
  <div data-te-modal-dialog-ref class="bg-white p-5 w-max mx-auto">
    <div data-te-modal-dismiss>
      <button type="button" data-te-toggle="modal" data-te-target="#create" class="rounded bg-secondary px-6 pb-2 pt-2.5 text-white">
        Create account
      </button>
    </div>
  </div>
</div>

<div
  data-te-modal-init
  class="fixed z-[1055] top-1/2 left-1/2 -translate-y-1/2 -translate-x-1/2 z-10 hidden"
  id="create"
  tabindex="-1"
  aria-hidden="true"
>
  <div data-te-modal-dialog-ref class="bg-white p-5 w-max mx-auto">
      <button type="button" class="rounded bg-primary px-6 pb-2 pt-2.5 text-white" data-te-modal-dismiss>
        Foo
      </button>
  </div>
</div>

<script src="https://cdn.jsdelivr.net/npm/tw-elements/dist/js/tw-elements.umd.min.js"></script>

相关问题