gpt4 book ai didi

css - 标题上方的顺风文本

转载 作者:行者123 更新时间:2023-12-05 02:55:31 25 4
gpt4 key购买 nike

我正在尝试学习 Tailwind 并创建像图像一样的设计。

该模板有一个导航栏和两列(左侧为粉红色,右侧为 img)。对于导航栏,我使用了绝对定位。但是下面的 h1 和文本呢?

如何垂直对齐 h1 和下面的文本?以及如何使 h1 向右移动并与图像重叠?

<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">

<!doctype html>
<html lang="ru">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="build/tailwind.css">
</head>

<body>

<!--NAV-->
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 absolute w-full">
<div class="flex justify-between h-16">
<div class="flex mx-auto">
<div class="flex-shrink-0 flex items-center">
LOGO
</div>
<div class="sm:ml-6 sm:flex">
<a href="#" class="inline-flex items-center px-1 pt-1 border-b-2 border-indigo-500 text-sm font-medium leading-5 focus:outline-none focus:border-indigo-700 transition duration-150 ease-in-out">
Dashboard
</a>
<a href="#" class="ml-8 inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
Team
</a>
<a href="#" class="ml-8 inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
Projects
</a>
<a href="#" class="ml-8 inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
Calendar
</a>
</div>
</div>
<div class="hidden sm:ml-6 sm:flex sm:items-center">
<a href="#" class="ml-8 inline-flex items-center px-1 pt-1 border-b-2 border-transparent text-sm font-medium leading-5 hover:text-gray-700 hover:border-gray-300 focus:outline-none focus:text-gray-700 focus:border-gray-300 transition duration-150 ease-in-out">
phone number
</a>
</div>
</div>
</div>

<!--Header-->
<div class="flex flex-wrap">
<!--Left col-->
<div class="w-full md:w-1/2 bg-pink-500">
<div class="items-center">
<h1 class="w-full text-4xl tracking-tight leading-10 font-extrabold text-gray-900 sm:text-5xl sm:leading-none md:text-6xl text-right my-auto pl-20">
Flowers delivery<br> in Moscow
</h1>
<div class="text-right pl-40">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Esse, placeat, totam. A consectetur, consequuntur enim est, facilis iure minus nisi officiis provident quasi, quis quisquam vel! Fugit itaque nemo veritatis.</div>
</div>
</div>
<!--Right col-->
<div class="w-full md:w-1/2">
<div style="max-width: 70%" class="">
<img src="https://sun9-59.userapi.com/c206720/v206720075/e9982/Ro2mvWfYfNE.jpg" class="py-20" alt="">
</div>

</div>
</div>

</body>

</html>

最佳答案

您可以使用负边距和 z-index

这是一个使用您的图像作为引用的工作示例

<!DOCTYPE html>
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
<link
href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
rel="stylesheet"
/>
</head>

<body>
<main class="text-gray-900">
<section class="flex min-h-screen">
<div class="w-full lg:w-1/2 bg-red-300 min-h-full z-10">
<header class="flex justify-between px-5">
<div>logo</div>
<nav>
<a href="#" class="mr-5">Main</a>
<a href="#" class="mr-5">Catalog</a>
<a href="#" class="mr-5">Contact</a>
<a href="#" class="mr-5">FAQ</a>
</nav>
</header>
<section class="flex items-center h-full">
<div class="text-right p-10">
<h1 class="text-5xl font-bold leading-none -mr-24 mb-10">
Flowers delivery<br />
in moscow
</h1>
<p class="pl-32 mb-10">
Lorem ipsum dolor sit amet consectetur adipisicing elit.
Accusamus sit perspiciatis maiores dolorum consequatur
obcaecati.
</p>
<a href="#" class="border-b border-gray-900 pb-2">Learn more</a>
</div>
</section>
</div>
<div class="w-full lg:w-1/2">
<div class="flex justify-end px-5">
<a href="tel:01-800-000-000">01-800-000-000</a>
</div>
<div>
<img
class="max-w-full"
src="https://images.unsplash.com/photo-1527061011665-3652c757a4d4?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=633&q=80"
alt=""
/>
</div>
</div>
</section>
</main>
</body>
</html>

这里是codesandbox的例子:https://codesandbox.io/s/gallant-fog-d33c1?file=/index.html

关于css - 标题上方的顺风文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61215064/

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