Hi I have been trying to create a list, displaying image items, but am having issues getting the images displaying horizontally, the overflow-x scroll bar is apperaing but the items not adjusting proparly. using tailwind-css.
This is the code for displaying the row items.
return (
<>
<h1 className='text-white font-bold ms-text-xl p-4'>{title}</h1>
<div className='relative flex items-center '>
<div className=' w-full h-full overflow-x-scroll whitespace-nowrap scroll-smooth scrollbar-hide relative inline-block'>
{movies?.map((item,id) => (
<Movie key={id} item={item} />
))}
</div>
</div>
</>
)
This is the code returns the movie images
return (
<div>
<div className='w-[160px] sm:w-[200px] md:w-[240px] lg:w-[280px] inline-block relative p-2'>
<img className='w-full h-auto block' src={`https://image.tmdb.org/t/p/w500/${item.backdrop_path}`} alt='movie?.title'/>
<div className='absolute top-0 left-0 w-full h-full hover:bg-black/80 opacity-0 hover:opacity-100 text-white'>
<p className=' whitespace-normal text-xs md:text-sm font-bold flex justify-center items-center h-full text-center ' >{item?.title}</p>
<div className='absolute flex items-center justify-end gap-2 right-2 top-2'>
<p className=' whitespace-normal text-xs md:text-sm font-medium text-yellow-500 text-center '>IMDb:⭐{item?.vote_average}</p>
<div>{wishlist ? <FaHeart className=''/> :<FaRegHeart className=' bg-red-600 '/> } </div>
</div>
</div>
</div>
</div>
)
This the result displying:
I just want to be able to displaying the images horizontally in the window and have the scroll bar to hide. like this:
in this wrapper div add flex overflow-x-hidden
<div className='flex overflow-x-hidden w-full h-full overflow-x-scroll whitespace-nowrap scroll-smooth scrollbar-hide relative inline-block'>
{movies?.map((item,id) => (
<Movie key={id} item={item} />
))}
</div>
Related
I got some starter code from a tutorial and I've been struggling to set the correct size. I've tried to find solutions via documentation but I feel like I'm missing something very basic. The issue that I am having is that the size of the box changes based on the content that is inside. I'd like a definitive size set regardless of the inside content. This is my code for the section:
<div className="flex flex-wrap -m-4">
{projects.map((project) => (
<a
href={project.link}
key={project.image}
rel="noopener noreferrer"
target="_blank"
className="flex w-1/2 h-full p-4">
<div className="flex relative">
<img
alt="gallery"
className="absolute inset-0 w-full h-full rounded-2xl object-cover object-center border-4 border-white"
src={project.image}
/>
<div className="px-8 py-10 relative z-0 w-full rounded-2xl border-4 border-gray-800 bg-gray-900 opacity-0 hover:opacity-100">
<h2 className="tracking-widest text-sm title-font font-medium text-orange-700 mb-1">
{project.subtitle}
</h2>
<h1 className="title-font text-lg font-medium text-white mb-3">
{project.title}
</h1>
<p className="leading-relaxed">{project.description}</p>
</div>
</div>
</a>
))}
</div>
Thank you!
On your a tag you have className="flex w-1/2 h-full p-4"> updating the h-full to be the specified height that you want should do the trick. The tailwind numbers will provide a value in em I believe. To get these to be a px value you can write the style like this: h-[50px] but include your desired height in the square brackets instead of teh 50px.
The goal is to hide an element behind a parent. There is a relative parent position, and a fixed child position, so when you scroll down, the fixed child will become visible and the parent will go up.
The image with yellow border shall go behind
Here's what I've tried:
<!-- hamburger menu -->
<div class="relative bg-white z-50 border-2 border-purple-900 w-[34%] h-auto flex justify-end items-center">
<div class="fixed top-6 right-1 z-20 border-2 border-yellow-500">
<a class="lg:hidden inline-block float-right text-red-600 mr-[3px] mt-1 p-[6px] bg-white rounded-full border-2 border-yagya-red" href="#">
<button id="mobile_menu1" class="relative outline-none w-7 h-7">
<div role="hidden" id="line" class="inset-0 w-4 h-0.5 m-auto rounded-full bg-yagya-red transition duration-300"></div>
<div role="hidden" id="line2" class="inset-0 w-4 h-0.5 mt-1 m-auto rounded-full bg-yagya-red transition duration-300"></div>
<div role="hidden" id="line2" class="inset-0 w-4 h-0.5 mt-1 m-auto rounded-full bg-yagya-red transition duration-300"></div>
</button>
</a>
</div>
</div>
thank you!
To add a z-index you have to use class:
z-10 : To bring that element forward
-z-10 : To bring that element backward
You can take the below example
<script src="https://cdn.tailwindcss.com"></script>
<!-- red with positive z-index -->
<div class="p-10">
<div class="w-24 h-24 bg-red-600 rounded-full z-10 absolute"></div>
<div class="w-24 h-24 bg-blue-600 rounded-full mt-10"></div>
</div>
<!-- red with negative z-index -->
<div class="p-10">
<div class="w-24 h-24 bg-red-600 rounded-full -z-10 absolute"></div>
<div class="w-24 h-24 bg-blue-600 rounded-full mt-10"></div>
</div>
FInd more here
I have following sample, written in tailwind css:
https://play.tailwindcss.com/f9iOK1e0oM
I want to have my control buttons on the bottom if the grid containers, however, they have different content sizes for the blue "tag" boxes, so the grid gets increased in height by some containers. however, as I am working with grid, all boxes are getting this height then. this is ok. But my control buttons should be always on the bottom of the containers, so that "Enabled" and "Delete" should not be so far away from bottom for the second container.
How to achieve this?
You need to add flex flex-col to the li element. And grow to the first child div and grow-0 max-h-max to the second child div.
<li class="flex flex-col col-span-1 divide-y divide-gray-200 rounded-lg bg-white shadow">
<div class=" grow flex w-full flex-col items-start justify-between p-6">
<div class="flex w-full items-start justify-between space-x-3">
<h3 class="truncate text-sm font-medium text-gray-900">243rfh83294d-23r8fj2n48r-24fi43bf</h3>
<span class="inline-block flex-shrink-0 rounded-full bg-green-100 px-2 py-0.5 text-xs font-medium text-green-800"> running </span>
</div>
<p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Interval: <span class="font-normal">1234</span></p>
<p class="mt-1 whitespace-pre-wrap text-xs font-bold text-gray-500">Next run: <span class="font-normal">1234</span></p>
<p class="mt-1 whitespace-pre-wrap">
<span class="inline-block flex-shrink-0 rounded-full bg-blue-100 px-2 py-0.5 text-xs text-blue-800">test 1</span>
</p>
</div>
<div>
<div class="-mt-px flex shrink-0 grow-0 divide-x divide-gray-200 max-h-max">
<div class="flex w-0 flex-1">
<button class="relative -mr-px inline-flex w-0 flex-1 items-center justify-center rounded-bl-lg border border-transparent py-4 text-sm font-medium text-gray-700 hover:text-gray-500">
<span class="ml-3">Enabled</span>
</button>
</div>
<div class="-ml-px flex w-0 flex-1">
<button class="group relative inline-flex w-0 flex-1 items-center justify-center rounded-br-lg border border-transparent py-4 text-sm font-medium text-gray-700 transition hover:text-red-500">
<span class="ml-3">Delete</span>
</button>
</div>
</div>
</div>
</li>
https://play.tailwindcss.com/ilTMM5glku
I have done this only for the second card, but you should do it for all cards. So that when the content changes, the button row will always stick to the bottom and keep the same height in all cards.
Hope this helps.
I'm currently working on a responsive layout for my cover letter, and I have stumbled upon a problem regarding responsiveness.
Desktop layout looks like this.
However, I have opted for hiding the text as well as the progress bar in mobile views, but the margin on chips is not uniform as you can see here.
I'm using this code for the computer skills section, since I figure that I can apply the solution to the section below. However, I will post more code if needed for context.
<div className="grid grid-rows-4 grid-cols-1 sm:grid-cols-3 items-center justify-center w-full">
<p className="text-center hidden md:block">Computer Skills</p>
<div className="flex flex-row gap-2 justify-center col-span-2 items-center">
<CustomButton text="STUB1" />
<ProgressBar width="w-full" />
</div>
<div className="col-span-1 m-2 sm:m-6" />
<div className="flex gap-2 justify-center col-span-2 items-center">
<CustomButton text="STUB2" />
<ProgressBar width="w-3/4" />
</div>
<div className="col-span-1 m-2 sm:m-6" />
<div className="flex gap-2 justify-center col-span-2 items-center mt-3 sm:mt-0">
<CustomButton text="STUB3" />
<ProgressBar width="w-3/4" />
</div>
<CustomLine ine isDashed="yes" />
</div>
Thank you so much for your help in advance.
try this if there would be, any responsive issue, then make responsive your components, that would be any issue ...!
<div className="grid grid-cols-1 grid sm:grid-cols-12 md:grid-cols-4 lg:grid-cols-4 xl:grid-cols-4 items-center justify-center w-full">
<p className="text-center hidden md:block">Computer Skills</p>
<div className="flex flex-row gap-2 justify-center col-span-2 items-center">
<CustomButton text="STUB1" />
<ProgressBar width="w-full" />
</div>
<div className="col-span-1 m-2 sm:m-6" />
<div className="flex gap-2 justify-center col-span-2 items-center">
<CustomButton text="STUB2" />
<ProgressBar width="w-3/4" />
</div>
<div className="col-span-1 m-2 sm:m-6" />
<div className="flex gap-2 justify-center col-span-2 items-center mt-3 sm:mt-0">
<CustomButton text="STUB3" />
<ProgressBar width="w-3/4" />
</div>
<CustomLine ine isDashed="yes" />
</div>
I'm using Tailwind CSS and I want to show the white dropdown over the modal.
I tried using z-index but I can't make it work.
Any ideas?
This is my modal code:
<TransitionRoot as="template" :show="isOpen">
<Dialog as="div" class="inset-0 fixed overflow-y-auto">
<div class="flex min-h-screen text-center px-4 pt-4 pb-20 items-end justify-center sm:p-0 sm:block">
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0" enter-to="opacity-100" leave="ease-in duration-200" leave-from="opacity-100" leave-to="opacity-0">
<DialogOverlay class="bg-gray-975 bg-opacity-85 inset-0 transition-opacity fixed" />
</TransitionChild>
<!-- This element is to trick the browser into centering the modal contents. -->
<span class="hidden sm:h-screen sm:inline-block sm:align-middle" aria-hidden="true"></span>
<TransitionChild as="template" enter="ease-out duration-300" enter-from="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95" enter-to="opacity-100 translate-y-0 sm:scale-100" leave="ease-in duration-200" leave-from="opacity-100 translate-y-0 sm:scale-100" leave-to="opacity-0 translate-y-4 sm:translate-y-0 sm:scale-95">
<div class="rounded-lg shadow-xl text-left transform transition-all text-gray-850 inline-block align-bottom overflow-hidden sm:max-w-lg sm:my-8 sm:w-full sm:align-middle dark:text-gray-200">
...
</div>
</TransitionChild>
</div>
</Dialog>
And this is my dropdown code:
<Listbox v-model="selectedPerson">
<div class="mt-1 relative z-50">
<ListboxButton
class="bg-white rounded-lg cursor-default shadow-md text-left w-full py-2 pr-10 pl-3 relative sm:text-sm focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-white focus-visible:ring-2 focus-visible:ring-opacity-75 focus-visible:ring-offset-orange-300 focus-visible:ring-offset-2">
<span class="block truncate">{{ selectedPerson.name }}</span>
<span class="flex pr-2 inset-y-0 right-0 absolute items-center pointer-events-none">
<SelectorIcon class="h-5 text-gray-400 w-5" aria-hidden="true" />
</span>
</ListboxButton>
...
</div>
Remove class overflow-hidden from <div class="rounded-lg shadow-xl text-left transform transition-all text-gray-850 inline-block align-bottom overflow-hidden sm:max-w-lg sm:my-8 sm:w-full sm:align-middle dark:text-gray-200">.
codesandbox
Change the class that sets the position of the child element from absolute to fixed