Issue
I have a hero page I load up in tailwind that has the wording on the left and a image on the right. However, The right side image is a paint roller and marks with some of the right side transparent to make it look like the screen is painted. When you resize the screen the right side of the image will cut off and that removes the effect. I am trying to change it so only the left side is cut off. Also on mobile I would like the image to show up still side by side with the hero section but just super cutoff on the right side so it doesnt take up too much screen and maybe cutoff the max screen size of the left column so the words stay more left.
I cannot seem to find any templates that act similarly in tailwind and all just push the image below the main and the primary hero section is pretty much a white background or something boring. This concept seemed more interesting.
My code is as follows:
<template>
<div class="relative bg-white">
<div class="mx-auto max-w-7xl lg:grid lg:grid-cols-12 lg:gap-x-8 lg:px-8">
<div class="px-6 pb-24 pt-10 sm:pb-32 lg:col-span-7 lg:px-0 lg:pb-56 lg:pt-48 xl:col-span-6">
<div class="mx-auto max-w-2xl lg:mx-0">
<div class="hidden sm:mt-32 sm:flex lg:mt-16">
<div class="relative rounded-full px-3 py-1 text-sm leading-6 text-gray-500 ring-1 ring-gray-900/10 hover:ring-gray-900/20">
Anim aute id magna aliqua ad ad non deserunt sunt. <a href="#" class="whitespace-nowrap font-semibold text-cyan-600"><span class="absolute inset-0" aria-hidden="true" />Read more <span aria-hidden="true">→</span></a>
</div>
</div>
<h1 class="mt-24 text-4xl font-bold tracking-tight text-gray-900 sm:mt-10 sm:text-6xl">Data to enrich your online business</h1>
<p class="mt-6 text-lg leading-8 text-gray-600">Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.</p>
<div class="mt-10 flex items-center gap-x-6">
<a href="#" class="rounded-md bg-cyan-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-cyan-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-600">Get started</a>
<a href="#" class="text-sm font-semibold leading-6 text-gray-900">Learn more <span aria-hidden="true">→</span></a>
</div>
</div>
</div>
<div class="relative lg:col-span-5 lg:-mr-8 xl:absolute xl:inset-0 xl:left-1/2 xl:mr-0">
<img class="aspect-[3/2] w-full bg-white object-cover lg:absolute lg:inset-0 lg:aspect-auto lg:h-full" src="~assets/img/hero-img.png" alt="" />
</div>
</div>
</div>
</template>
Here is a screen shot as well of both desktop and mobile and the issues at hand I am facing:
Solution
When you resize the screen the right side of the image will cut off and that removes the effect. I am trying to change it so only the left side is cut off.
I assume you mistyped here and that you want only the right side to cut off. If so, consider apply object-position: left
to the <img>
by adding the object-left
class:
<script src="https://cdn.tailwindcss.com/3.4.1"></script>
<div class="relative bg-white">
<div class="mx-auto max-w-7xl lg:grid lg:grid-cols-12 lg:gap-x-8 lg:px-8">
<div class="px-6 pb-24 pt-10 sm:pb-32 lg:col-span-7 lg:px-0 lg:pb-56 lg:pt-48 xl:col-span-6">
<div class="mx-auto max-w-2xl lg:mx-0">
<div class="hidden sm:mt-32 sm:flex lg:mt-16">
<div class="relative rounded-full px-3 py-1 text-sm leading-6 text-gray-500 ring-1 ring-gray-900/10 hover:ring-gray-900/20">
Anim aute id magna aliqua ad ad non deserunt sunt. <a href="#" class="whitespace-nowrap font-semibold text-cyan-600"><span class="absolute inset-0" aria-hidden="true" />Read more <span aria-hidden="true">→</span></a>
</div>
</div>
<h1 class="mt-24 text-4xl font-bold tracking-tight text-gray-900 sm:mt-10 sm:text-6xl">Data to enrich your online business</h1>
<p class="mt-6 text-lg leading-8 text-gray-600">Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.</p>
<div class="mt-10 flex items-center gap-x-6">
<a href="#" class="rounded-md bg-cyan-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-cyan-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-600">Get started</a>
<a href="#" class="text-sm font-semibold leading-6 text-gray-900">Learn more <span aria-hidden="true">→</span></a>
</div>
</div>
</div>
<div class="relative lg:col-span-5 lg:-mr-8 xl:absolute xl:inset-0 xl:left-1/2 xl:mr-0">
<img class="aspect-[3/2] w-full bg-white object-cover object-left lg:absolute lg:inset-0 lg:aspect-auto lg:h-full" src="https://iili.io/JYpMHaj.webp" alt="" />
</div>
</div>
</div>
For mobile, you could consider some sort flex or grid layout:
<script src="https://cdn.tailwindcss.com/3.4.1"></script>
<div class="relative bg-white">
<div class="flex mx-auto max-w-7xl lg:grid lg:grid-cols-12 lg:gap-x-8 lg:px-8">
<div class="px-6 pb-24 pt-10 sm:pb-32 lg:col-span-7 lg:px-0 lg:pb-56 lg:pt-48 xl:col-span-6">
<div class="mx-auto max-w-2xl lg:mx-0">
<div class="hidden sm:mt-32 sm:flex lg:mt-16">
<div class="relative rounded-full px-3 py-1 text-sm leading-6 text-gray-500 ring-1 ring-gray-900/10 hover:ring-gray-900/20">
Anim aute id magna aliqua ad ad non deserunt sunt. <a href="#" class="whitespace-nowrap font-semibold text-cyan-600"><span class="absolute inset-0" aria-hidden="true" />Read more <span aria-hidden="true">→</span></a>
</div>
</div>
<h1 class="mt-24 text-4xl font-bold tracking-tight text-gray-900 sm:mt-10 sm:text-6xl">Data to enrich your online business</h1>
<p class="mt-6 text-lg leading-8 text-gray-600">Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.</p>
<div class="mt-10 flex items-center gap-x-6">
<a href="#" class="rounded-md bg-cyan-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-cyan-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-600">Get started</a>
<a href="#" class="text-sm font-semibold leading-6 text-gray-900">Learn more <span aria-hidden="true">→</span></a>
</div>
</div>
</div>
<div class="relative basis-10 grow lg:col-span-5 lg:-mr-8 xl:absolute xl:inset-0 xl:left-1/2 xl:mr-0">
<img class="w-full bg-white object-cover object-left absolute inset-0 h-full" src="https://iili.io/JYpMHaj.webp" alt="" />
</div>
</div>
</div>
<script src="https://cdn.tailwindcss.com/3.4.1"></script>
<div class="relative bg-white">
<div class="mx-auto max-w-7xl grid grid-cols-[90%_10%] lg:grid-cols-12 lg:gap-x-8 lg:px-8">
<div class="px-6 pb-24 pt-10 sm:pb-32 lg:col-span-7 lg:px-0 lg:pb-56 lg:pt-48 xl:col-span-6">
<div class="mx-auto max-w-2xl lg:mx-0">
<div class="hidden sm:mt-32 sm:flex lg:mt-16">
<div class="relative rounded-full px-3 py-1 text-sm leading-6 text-gray-500 ring-1 ring-gray-900/10 hover:ring-gray-900/20">
Anim aute id magna aliqua ad ad non deserunt sunt. <a href="#" class="whitespace-nowrap font-semibold text-cyan-600"><span class="absolute inset-0" aria-hidden="true" />Read more <span aria-hidden="true">→</span></a>
</div>
</div>
<h1 class="mt-24 text-4xl font-bold tracking-tight text-gray-900 sm:mt-10 sm:text-6xl">Data to enrich your online business</h1>
<p class="mt-6 text-lg leading-8 text-gray-600">Anim aute id magna aliqua ad ad non deserunt sunt. Qui irure qui lorem cupidatat commodo. Elit sunt amet fugiat veniam occaecat fugiat aliqua.</p>
<div class="mt-10 flex items-center gap-x-6">
<a href="#" class="rounded-md bg-cyan-600 px-3.5 py-2.5 text-sm font-semibold text-white shadow-sm hover:bg-cyan-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-cyan-600">Get started</a>
<a href="#" class="text-sm font-semibold leading-6 text-gray-900">Learn more <span aria-hidden="true">→</span></a>
</div>
</div>
</div>
<div class="relative lg:col-span-5 lg:-mr-8 xl:absolute xl:inset-0 xl:left-1/2 xl:mr-0">
<img class="w-full bg-white object-cover object-left absolute inset-0 h-full" src="https://iili.io/JYpMHaj.webp" alt="" />
</div>
</div>
</div>
Answered By - Wongjn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.