gpt4 book ai didi

css - tailwind css - 无法让元素填写页面,总是卡在较小的容器中

转载 作者:行者123 更新时间:2023-12-04 11:29:44 28 4
gpt4 key购买 nike

我试图让我的页面看起来与此类似 https://dash.blinq.app/onboarding/personal-details
目前使用此代码,我使用顺风获得了非常糟糕的 flex 样式,我似乎无法弄清楚如何正确修复它。

    import { ChevronRightIcon, HomeIcon } from '@heroicons/react/solid'

const pages = [
{ name: 'Privacy', href: '#', current: false },
{ name: 'Customizations', href: '#', current: true },
{ name: 'Details', href: '#', current: true },


]

function BreadCrumbs() {
return (
<nav className="flex" aria-label="Breadcrumb">
<ol className="flex items-center space-x-4">
<li>
<div>
<a href="#" className="text-gray-400 hover:text-gray-500">
<HomeIcon className="flex-shrink-0 h-5 w-5" aria-hidden="true" />
<span className="sr-only">Home</span>
</a>
</div>
</li>
{pages.map((page) => (
<li key={page.name}>
<div className="flex items-center">
<ChevronRightIcon className="flex-shrink-0 h-5 w-5 text-gray-400" aria-hidden="true" />
<a
href={page.href}
className="ml-4 text-sm font-medium text-gray-500 hover:text-gray-700"
aria-current={page.current ? 'page' : undefined}
>
{page.name}
</a>
</div>
</li>
))}
</ol>
</nav>
)
}





export default function Example() {
return (
<div className="min-h-screen bg-white flex">
<div className="hidden lg:block relative w-6/12 flex-auto">
<img
className="absolute inset-0 h-full object-cover"
src="https://images.unsplash.com/photo-1505904267569-f02eaeb45a4c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1908&q=80"
alt=""
/>
</div>
<div className="flex-1 flex flex-col justify-center py-12 px-4 sm:px-6 lg:flex-none lg:px-20 xl:px-24">
<BreadCrumbs/>

<div className="mx-auto w-full max-w-lg lg:w-96">
<div>

<h2 className="mt-6 text-3xl font-extrabold text-gray-900">Welcome to Moodmap</h2>
<p className="mt-2 text-sm text-gray-600">
Let's get you started!


</p>
</div>

<div className="mt-8">


<div className="mt-6">
<form action="#" method="POST" className="space-y-6">
<div>
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
Email address
</label>
<div className="mt-1">
<input
id="email"
name="email"
type="email"
autoComplete="email"
required
className="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</div>
</div>

<div className="space-y-1">
<label htmlFor="password" className="block text-sm font-medium text-gray-700">
Password
</label>
<div className="mt-1">
<input
id="password"
name="password"
type="password"
autoComplete="current-password"
required
className="appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
/>
</div>
</div>



<div>
<button
type="submit"
className="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
Next
</button>
</div>
</form>
</div>
</div>
</div>
</div>

</div>
)
}
看起来有点像这样。
enter image description here
我如何获得 flex 以允许表单正确安装?
谢谢!

最佳答案

我猜你希望登录表单和面包屑占据更大的空间。

  • 将图像从屏幕尺寸的一半缩小到 1/3 尺寸(移除 w-6/12 flex-auto)。
  • 删除第二个 div 上的 lg:flex-none。
  • 删除登录框的宽度限制(删除 max-w-lg lg:w-96 )

  • 这应该使表单 flex 到剩余的 2/3 空间。
    import { ChevronRightIcon, HomeIcon } from '@heroicons/react/solid'

    const pages = [
    { name: 'Privacy', href: '#', current: false },
    { name: 'Customizations', href: '#', current: true },
    { name: 'Details', href: '#', current: true },


    ]

    function BreadCrumbs() {
    return (
    <nav className="flex" aria-label="Breadcrumb">
    <ol className="flex items-center space-x-4">
    <li>
    <div>
    <a href="#" className="text-gray-400 hover:text-gray-500">
    <HomeIcon className="flex-shrink-0 w-5 h-5" aria-hidden="true" />
    <span className="sr-only">Home</span>
    </a>
    </div>
    </li>
    {pages.map((page) => (
    <li key={page.name}>
    <div className="flex items-center">
    <ChevronRightIcon className="flex-shrink-0 w-5 h-5 text-gray-400" aria-hidden="true" />
    <a
    href={page.href}
    className="ml-4 text-sm font-medium text-gray-500 hover:text-gray-700"
    aria-current={page.current ? 'page' : undefined}
    >
    {page.name}
    </a>
    </div>
    </li>
    ))}
    </ol>
    </nav>
    )
    }





    export default function Example() {
    return (
    <div className="flex min-h-screen bg-white">
    <div className="relative w-4/12 lg:block">
    <img
    className="absolute inset-0 object-cover h-full"
    src="https://images.unsplash.com/photo-1505904267569-f02eaeb45a4c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1908&q=80"
    alt=""
    />
    </div>
    <div className="flex flex-col justify-center flex-1 px-4 py-12 sm:px-6 lg:px-20 xl:px-24">
    <BreadCrumbs/>

    <div className="w-full ">
    <div>

    <h2 className="mt-6 text-3xl font-extrabold text-gray-900">Welcome to Moodmap</h2>
    <p className="mt-2 text-sm text-gray-600">
    Let's get you started!


    </p>
    </div>

    <div className="mt-8">


    <div className="mt-6">
    <form action="#" method="POST" className="space-y-6">
    <div>
    <label htmlFor="email" className="block text-sm font-medium text-gray-700">
    Email address
    </label>
    <div className="mt-1">
    <input
    id="email"
    name="email"
    type="email"
    autoComplete="email"
    required
    className="block w-full px-3 py-2 placeholder-gray-400 border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
    />
    </div>
    </div>

    <div className="space-y-1">
    <label htmlFor="password" className="block text-sm font-medium text-gray-700">
    Password
    </label>
    <div className="mt-1">
    <input
    id="password"
    name="password"
    type="password"
    autoComplete="current-password"
    required
    className="block w-full px-3 py-2 placeholder-gray-400 border border-gray-300 rounded-md shadow-sm appearance-none focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"
    />
    </div>
    </div>



    <div>
    <button
    type="submit"
    className="flex justify-center w-full px-4 py-2 text-sm font-medium text-white bg-indigo-600 border border-transparent rounded-md shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
    >
    Next
    </button>
    </div>
    </form>
    </div>
    </div>
    </div>
    </div>

    </div>
    )
    }

    关于css - tailwind css - 无法让元素填写页面,总是卡在较小的容器中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67960134/

    28 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com