简体   繁体   English

有什么办法可以让这个元素在屏幕上居中吗?

[英]Is there any way to center this element to screen?

I am starting out using Tailwind with React and I am stuck on this.我开始将 Tailwind 与 React 结合使用,但我一直坚持这一点。 I tried various methods but still I am stuck.我尝试了各种方法,但仍然卡住了。 Here is the code and view snippet.这是代码和视图片段。

 import { Navbar, Welcome, Footer, Services, Transactions } from "./components"; const App = () => { return ( <div className="min-h-screen"> <div className="h-14 bg-gradient-to-r from-purple-500 to-red-500 border-double rounded-b-3xl border-b-8 w-5/6"> <Welcome /> </div> <div className="h-14 bg-gradient-to-b from-blue-500 to-green-500 rounded-lg w-1/2 flex justify-center "> <Services /> </div> <Transactions /> <Footer /> </div> ); } export default App;

在此处输入图像描述

Have you try adding mx-auto class to your gradient divs?您是否尝试将mx-auto class 添加到您的渐变 div 中? If that doesn't work you could also try text-center in your main div.如果这不起作用,您也可以在主 div 中尝试text-center

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM