I have a Vue3 carousel inside a Single file component
package.json
"vue3-carousel": "^0.1.40"
SFC
import { Carousel, Slide, Navigation } from 'vue3-carousel';
import 'vue3-carousel/dist/carousel.css';
import '#/assets/scss/Carousel.scss';
<Carousel :wrap-around="true" class="box-carousel" :autoplay="2000" :transition="500">
<Slide v-for="slide in slides" :key="slide.id">
<div class="mx-auto w-[85%] md:w-[90%] rounded-lg p-5 bg-blue-secondary-5 h-full dark:bg-blue-secondary-5 dark:text-black-dark-100">
<!-- Box Description -->
<div class="grid grid-cols-5 gap-5 mb-5">
<div class="col-span-1">
<div class="rounded-full h-11 w-11 bg-black-20 flex items-center justify-center">
<p class="uppercase font-bold text-sm">{{slide.title}}</p>
</div>
</div>
<div class="col-span-4 text-left">
<div class="ml-3 md:ml-0">
<p class="font-bold">{{slide.name}}</p>
<p class="text-black-40 text-xs">{{slide.date}}</p>
</div>
</div>
</div>
<!-- End Box Description -->
<!-- Box Comment -->
<div class="text-left mb-8">
<p class="text-sm ">
{{slide.comment.substring(0,130)}}
</p>
</div>
<!-- End Box Comment -->
<!-- Box Actions -->
<div class="grid grid-cols-6 gap-5 absolute bottom-5">
<div class="col-span-2">
<a href="javascript:void(0)" class="flex items-center text-xs md:text-sm relative top-1 text-blue-secondary-100">
<UndoIcon width="10" class="fill-blue-secondary-100 mr-2 hidden md:block" />
Responder
</a>
</div>
<div class="col-span-2">
<a href="javascript:void(0)" class="flex items-center text-xs md:text-sm relative top-1 text-black-40 underline">
Ver contexto
</a>
</div>
<div class="col-span-2">
<p class="text-xs md:text-sm flex items-center justify-end md:justify-start relative top-1">
<span class="h-2 w-2 rounded-full bg-green-primary-100 inline-block mr-5 md:mr-1 relative top-[-1px]"></span>
<span class="hidden md:block">aprovado</span>
</p>
</div>
</div>
<!-- End Box Actions -->
</div>
</Slide>
<template #addons>
<Navigation />
</template>
</Carousel>
But the transition behavior of the slides is not as expected. It is just changing withouth the transition/translate position effect
This is how it is:
Expected effect: (by the way, the carousel sometimes spontaneously display the expected behavior like when after some hot module replacement refresh happens after saving some edit in VSCode and there is a refresh in the vue app like this):
Thanks in advance for any advice!! Happy new year !! 🙂
Related
I'm new to Tailwind and my setup works on Firefox, but not with Google Chrome. Is there some sort of webkit issue that I might be missing? I have tested my code on various versions. Weirdly with dev tools it does work on Chrome. However the deploy doesn't work on Google or Android phone. All styles are applied except the resizing elements, so my phone just displays a monitor webpage.
function Header() {
return (
<>
<section
id='hero'
className='px-4 py-8 mx-auto sm:max-w-xl md:max-w-full lg:max-w-screen-xl md:px-24 lg:px-8'
>
<div className='flex flex-col items-center justify-between w-full mb-10 lg:flex-row'>
<div className='mb-16 lg:mb-0 lg:max-w-lg lg:pr-5 lg:pl-5'>
<article className='max-w-xl mb-6'>
<div>
<h4 className='inline-block font-semibold tracking-wider uppercase text-eco-green rounded-full'>
Brand new web project
</h4>
</div>
<h1 className='text-eco-green font-extrabold text-6xl pb-6 md:py-4 text-center md:text-left'>
myecoapp
</h1>
<h2 className='font-sans text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl sm:leading-none max-w-lg mb-6'>
Help The Planet <br className='hidden md:block' />
by existing{' '}
<span className='inline-block text-deep-purple-accent-400'>
and clicking
</span>
</h2>
<p className='text-gray-700 text-base md:text-lg'>
Help the environment from anywhere for free! At home or at any
event. Use our apps to earn while you relax. We have done what
we can to provide entertainment for you. Check it out below.
</p>
</article>
<div className='flex items-center space-x-3'>
<CTA />
</div>
</div>
{/* Phones */}
<div className='flex h-full items-center justify-center lg:w-1/2'>
<div className='w-2/5'>
<img
className='object-cover'
src='https://kitwind.io/assets/kometa/one-girl-phone.png'
alt=''
/>
</div>
<div className='w-5/12 -ml-16 lg:-ml-32'>
<img
className='object-cover'
src='https://kitwind.io/assets/kometa/two-girls-phone.png'
alt=''
/>
</div>
</div>
</div>
</section>
</>
)}
<html>
<body>
<div class="group card my-14 mx-3 w-80 h-100 bg-gray-800 rounded-xl text-white p-5 cursor-pointer">
<div class=" flex justify-between items-center text-2xl ">
<i class='bx bx-heart'></i>
<i class='bx bx-cart-alt'></i>
</div>
<div class="w-11/12 ml-2.5 group-hover:text-white group-hover:-rotate-20">
<img class="object-cover w-full h-full" src="./Images/Jordan.png" id="bannerImage" alt="">
</div>
<div class="text-center uppercase text-xl text-green-600">
Jordan 1 <br>
$299
</div>
</div>
</body>
</html>
Explain why Styling based on parent state doesn't work.
...................................
Tailwind doesn't have -rotate-20 utility class. Change it to one of known or use arbitrary value like group-hover:-rotate-[20deg]
Either svelte or tailwind transitions.
This is basically copied from the tailwind components page with some changes to make it work as best as I knew how with svelte. The tailwind component page says it requires JS, but I cannot find any examples of the kind of JS that would be expected in order for it to work the way it does on the component page.
There's a comment block of tailwind classes, but I cannot find docs on how they are to be used.
The side panel works, as in it hides and shows and all the clicks are appropriate, but it snaps. I'd like it to slide in from the side.
How do I make it do a sliding anim/transition?
<aside
class="relative z-10 "
aria-labelledby="slide-over-title"
role="dialog"
aria-modal="true"
class:block={showSidePanel} << my toggle variable in Svelte
class:hidden={!showSidePanel}
on:click|stopPropagation|preventDefault={toggleSidePanel}
transition:fly={{ x: 200, duration: 300 }}
>
<!--
Background backdrop, show/hide based on slide-over state.
Entering: "ease-in-out duration-500"
From: "opacity-0"
To: "opacity-100"
Leaving: "ease-in-out duration-500"
From: "opacity-100"
To: "opacity-0"
-->
<div
class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
class:block={showSidePanel}
class:hidden={!showSidePanel}
/>
<div class="fixed inset-0 overflow-hidden">
<div class="absolute inset-0 overflow-hidden">
<div class="absolute inset-y-0 right-0 mt-20 flex max-w-full pl-10">
<!--
Slide-over panel, show/hide based on slide-over state.
Entering: "transform transition ease-in-out duration-500 sm:duration-700"
From: "translate-x-full"
To: "translate-x-0"
Leaving: "transform transition ease-in-out duration-500 sm:duration-700"
From: "translate-x-0"
To: "translate-x-full"
-->
<div
class="my-auto h-full w-screen max-w-2xl"
on:click|stopPropagation|preventDefault={() => {
// this blocks clicks closing the sidepanel
}}
>
<div
class="m-auto flex h-[95%] flex-col overflow-y-scroll bg-white py-6 shadow-xl"
>
<div class="px-4 sm:px-6">
<div class="flex items-start justify-between">
<h2
class="text-lg font-medium text-gray-900"
id="slide-over-title"
>
Panel title
</h2>
<div class="ml-3 flex h-7 items-center">
<button
type="button"
class="rounded-md bg-white font-bold text-gray-400 hover:text-gray-500"
on:click|stopPropagation={toggleSidePanel}
>
<span class="sr-only">Close panel</span>
<Icon src={X} theme="solid" class="h-8 w-8 font-bold" />
</button>
</div>
</div>
</div>
<div class="relative mt-6 flex-1 px-4 sm:px-6">
<!-- Replace with your content -->
<div class="absolute inset-0 px-4 sm:px-6">
<div
class="h-full border-2 border-dashed border-gray-200"
aria-hidden="true"
/>
</div>
<!-- /End replace -->
</div>
</div>
</div>
</div>
</div>
</div>
</aside>
Instead of using classes to hide or show your sidebar you should use an {#if} block wrapped around the entire aside element to hide and show the sidebar and overlay.
Then you can use the Svelte transition that is right for each element. In the Tailwind comments it's using translate-x-full for the panel transition to get a similar effect you can bind the clientWidth of the actual panel to a variable and use that as the x amount in your Svelte fly transition.
Something like this (I removed some of your code since you had no components linked and used Tailwind CDN so the Tailwind classes would work like in this REPL):
<script>
import { fly, fade } from 'svelte/transition'
let showSidePanel, width
function toggleSidePanel() {
showSidePanel = !showSidePanel
}
</script>
<svelte:head>
<script src="https://cdn.tailwindcss.com"></script>
</svelte:head>
<div>
<button class="p-3" on:click={toggleSidePanel}>
Show side panel
</button>
</div>
{#if showSidePanel}
<aside class="relative z-10">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity" transition:fade/>
<div class="fixed inset-0 overflow-hidden">
<div class="absolute inset-0 overflow-hidden">
<div class="absolute inset-y-0 right-0 mt-20 flex max-w-full pl-10">
<div class="my-auto h-full w-screen max-w-2xl">
<div bind:clientWidth={width} transition:fly={{ x: width }} class="m-auto flex h-[95%] flex-col overflow-y-scroll bg-white py-6 shadow-xl">
<div class="px-4 sm:px-6">
<div class="flex items-start justify-between">
<h2 class="text-lg font-medium text-gray-900">
Panel title
</h2>
<div class="ml-3 flex h-7 items-center">
<button class="rounded-md bg-white font-bold text-gray-400 hover:text-gray-500" on:click={toggleSidePanel}>
close
</button>
</div>
</div>
</div>
<div class="relative mt-6 flex-1 px-4 sm:px-6">
<div class="absolute inset-0 px-4 sm:px-6">
<div class="h-full border-2 border-dashed border-gray-200" aria-hidden="true">Some content</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</aside>
{/if}
I need to add 2 children of a parent element one on the top and another on the bottom. something like this.
and this is the code I have.
<div class=" w-full flex justify-betwen bg-white items-center">
<div class="ml-auto">
<img class="object-cover mr-2 md:mr-4 ml-2 md:ml-4 float-left h-40 lg:w-32 w-14 xs:w-16"
src="../img/Bless.png" alt="" />
</div>
<div class="w-full mx-8">
<div class="text-redfull text-ms xs:text-lg md:text-xl lg:text-2xl xl:text-3xl">
Some text here to top as a title.
</div>
<div
class=" text-gray70 flex justify-between items-center text-xs xs:text-base md:text-base lg:text-lg mb-0">
and this is the date to the bottom Uploaded Auguts 4, 2020
</div>
</div>
</div>
Title should stay at the top.
Date to the bottom.
If anyone knows:)
You can add two divs for Title and Date and add vertical margin to them.
I am not sure whether you want with the text or not so I had implemented for both the cases.
Case 1: With text
<script src="https://cdn.tailwindcss.com"></script>
<div class="justify-betwen flex w-full items-center bg-white">
<div class="ml-auto">
<img class="xs:w-16 float-left mr-2 ml-2 h-40 w-14 object-cover md:mr-4 md:ml-4 lg:w-32" src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.s2014.png" alt="" />
</div>
<div class="mx-8 w-full">
<div class="text-3xl font-semibold text-red-900">Your Title here</div>
<div class="my-3">
<div class="text-ms xs:text-lg text-red-500 md:text-xl lg:text-2xl xl:text-3xl">Some text here to top as a title.</div>
<div class="xs:text-base mb-0 flex items-center justify-between text-xs text-gray-500 md:text-base lg:text-lg">and this is the date to the bottom Uploaded Auguts 4, 2020</div>
</div>
<div class="text-base font-extralight">25 June 2022</div>
</div>
</div>
Case 2: Without Text
<script src="https://cdn.tailwindcss.com"></script>
<div class="justify-betwen flex w-full items-center bg-white">
<div class="ml-auto">
<img class="xs:w-16 float-left mr-2 ml-2 h-40 w-14 object-cover md:mr-4 md:ml-4 lg:w-32" src="http://commondatastorage.googleapis.com/codeskulptor-assets/lathrop/nebula_blue.s2014.png" alt="" />
</div>
<div class="mx-8 w-full">
<div class="text-3xl font-semibold text-red-900">Your Title here</div>
<div class="my-12">
</div>
<div class="text-lg font-extralight">25 June 2022</div>
</div>
</div>
I had use an online image, so you can replace it with your image.
If You want more gap, then simply increase the my-12 to more.
I have section areas that I want to have equal elements. One side is just an image while the other side has content. I'm using Tailwind CSS and feel positive I have the correct classes. The section Divs are declared as Flex while the child elements each have a Flex-basis of 0 and a Flex grow of 1. The content div continues to be a little larger than my image div.
<section class="section-one flex flex-col-reverse md:flex-row-reverse">
<div class="basis-0 grow p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
<div>
<h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
<p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
<div class="flex flex-col">
Learn More
<span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
</div>
</div>
</div>
<div class="basis-0 grow">
<img src="images/desktop/image-stand-out.jpg" alt="" class="w-full" />
</div>
</section>
If you remove your p-6 class and add in the div below it will work.
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" integrity="sha512-wnea99uKIC3TJF7v4eKk4Y+lMz2Mklv18+r4na2Gn1abDRPPOeef95xTzdwGD9e6zXJBteMIhZ1+68QC5byJZw==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<section class="section-one flex flex-col-reverse md:flex-row-reverse">
<div class="basis-0 grow remove-this-p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
<div class="p-6"> <!-- add here your padding -->
<h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
<p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
<div class="flex flex-col">
Learn More
<span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
</div>
</div>
</div>
<div class="basis-0 grow">
<img src="https://via.placeholder.com/500" alt="" class="w-full" />
</div>
</section>
<section class="section-one flex flex-col-reverse md:flex-row-reverse ">
<div class="basis-0 grow">
<img src="https://via.placeholder.com/500" alt="" class="w-full" />
</div>
<div class="basis-0 grow remove-this-p-6 text-center md:text-left md:flex md:flex-col md:justify-center md:items-center">
<div class="p-6"><!-- add here your pading -->
<h2 class="font-fraunces text-4xl mb-4 md:text-left md:max-w-md">Stand our to the right audience</h2>
<p class="font-barlow text-gray-500 text-lg p-4 mb-6 md:max-w-md md:p-0">Using a collaborative formula of designers, researchers, photographers, videographers and copywriters, we'll build and extend your brand in digital places.</p>
<div class="flex flex-col">
Learn More
<span class="bg-rose-300/75 w-32 mx-auto h-4 rounded-full md:m-0"></span>
</div>
</div>
</div>
</section>
By using grid you can achieve this
Here is the best explanation how to use grid system in tailwindcss
I have made code for you please check here: https://play.tailwindcss.com/wldkQ1txrU