tailwind-css - 在全屏 div 中与 Tailwind CSS 垂直对齐
问题描述
如何将 div 与 Tailwind 垂直对齐?我想要的是:
-----------------------------------
| |
| |
| |
| item1 |
| item2 |
| |
| |
| |
-----------------------------------
我目前拥有的:
-----------------------------------
| item1 |
| item2 |
| |
| |
| |
| |
| |
| |
-----------------------------------
HTML
<div class="flex flex-col h-screen my-auto items-center bgimg bg-cover">
<h3 class="text-white">heading</h3>
<button class="mt-2 bg-white text-black font-bold py-1 px-8 rounded m-2">
call to action
</button>
</div>
CSS
.bgimg {
background-image: url('https://d1ia71hq4oe7pn.cloudfront.net/photo/60021841-480px.jpg');
}
我已经成功地以 class 为中心在辅助轴(左右)上items-center
。阅读文档,我尝试过,align-middle
但它不起作用。我已经确认 div 具有全高和my-auto
.
我正在使用这个版本的 Tailwind:https ://cdn.jsdelivr.net/npm/tailwindcss/dist/tailwind.min.css
这是一个 JSFiddle:https ://jsfiddle.net/7xnghf1m/2/
解决方案
你也可以做
<div class="flex h-screen">
<div class="m-auto">
<h3>title</h3>
<button>button</button>
</div>
</div>
推荐阅读
- c++ - 如何将 Qt 与 Visual Studio C++ 应用程序项目联系起来?
- android - 为什么searchview只输出listview上的第一项?
- javafx - Javafx - 为条形图设置悬停
- javascript - 我无法在 javascript 中访问 radgrid 列..我如何访问这个..?
- javascript - 当我们使用 css 下拉菜单作为共享组件时如何设置和获取表单值
- python - numpy sum min max 函数在聚合或应用于列表或数组时的不同行为
- uri - 当模式导入中的反斜杠和指定的绑定时,XJC 失败
- azure-devops - 如何触发 PR 构建?
- python - 如何可靠地从 TCP 套接字中准确读取 n 个字节?
- flex-lexer - 如何将 flex 令牌与另一个令牌重新协调?