【问题标题】:Vertically center a loader using tailwindCSS with Laravel Nova dashboard使用 tailwindCSS 和 Laravel Nova 仪表板垂直居中加载器
【发布时间】:2021-01-11 15:01:07
【问题描述】:

我有一个空页面,我想在重定向之前显示一个加载器。

 <template>
    <span class="flex flex-col items-center justify-center h-screen ">
        <atom-spinner
            :animation-duration="1000"
            :size="160"
            :color="'#1f6492'"
        />
    </span>
</template>

<script>
import {AtomSpinner} from 'epic-spinners'

export default {
    props: [
        'card',
    ],
    components: {
        AtomSpinner
    },

    mounted() {
    },
}
</script>

如果我这样做,h-screen 类将采用屏幕大小,而不采用标题大小和边距。所以,最后,它不会垂直居中。

如果我有办法用 填充我的屏幕,我可以轻松做到

我应该如何让加载器在屏幕中心居中?

这是一个截图:

【问题讨论】:

标签: css tailwind-css


【解决方案1】:

一小段内联 CSS 就可以解决问题:

<span class="flex flex-col items-center justify-center" style="height:calc(100% - 60px);">
  <atom-spinner
    :animation-duration="1000"
    :size="160"
    :color="'#1f6492'"
  />
</span>

60px 值应调整为与标题的高度匹配。

可能有更好的方法,但假设您无权访问包装标题和内容区域的父元素,我想不起来有一个 Tailwind 类可以管理这个。

【讨论】:

  • 是的,它成功了!我必须添加 !important 才能正常工作。
猜你喜欢
  • 2023-01-19
  • 2020-12-24
  • 2019-06-22
  • 1970-01-01
  • 1970-01-01
  • 2011-06-21
  • 2014-06-18
  • 2021-09-02
  • 1970-01-01
相关资源
最近更新 更多