I have a React Gatsby web app and I have a component that renders answer cards with an image on each card. I know there is a known issue with windows 10 and chrome which is fixed by disabling hardware acceleration, but my site is the only one that I have such bad flickering. I have tried to refactor everything to have the best performance but the issue persists.
I know that this Google Chrome Flicker Unable to Find Cause
solves the issue, but users will not do this since even for me this is the only site that this happens.
My components look something like this.
<div className="flex flex-wrap justify-center py-10 px-8">
{answers.map((e) => (
<Field key={e.id} type="radio" name={id} value={e.answerId}>
{() => {
return (
<div
onClick={onClick}
className="flex flex-col justify-around w-32 h-44 2k:w-48 2k:h-72 shadow-3xl rounded-md mx-2 my-3 cursor-pointer transform transition-transform"
>
<div className="flex-1" />
<div className="inline-block px-2 m-3">
<img src="https://w7.pngwing.com/pngs/247/929/png-transparent-potato-food-anime-potato-food-manga-cartoon.png" />
</div>
</div>
);
}}
</Field>
))}
</div>
I have tried almost everything. Removing flex does not fix the issue. If I remove the image the issue is fixed. Any help appreciated.
Found it. Although in general the flickering issue with Chrome + Windows is fixed, it seems that there are cases where hardware acceleration is still struggling.
In my case I had a div element with filter grayscale CSS and both box-shadow applied (for the card unselected state above). Probably chrome renderer had issues applying the filter to the box-shadow element so that caused the flickering. I moved the filter to the inside image element (which makes more sense either way) and the issue was fixed.
Related
I'm making a website using react and tailwind. I want to add a vertical scrollbar to a list in a section of my page, but when I do, the bullets disappear. Why is this happening?
<ul className="list-disc overflow-y-auto h-80 space-y-3 text-sm w-full sm:text-md items-start">
{experience.points.map((point, i) => (
<li key={i}>{point}</li>
))}
</ul>
I've tried using overflow-y-scroll instead but it has the same effect. I've also tried adjusting the margins of the list container but that doesn't work either. The bullets appear when I don't use any overflow utility. For now, I've just added them to each list-item string manually but I'm curious as to why this would happen.
what you are missing is the css rule that sets the counter inside or outside
in tailwind 3 it's the class list-inside
plain css: list-style-position: inside;
being it set outside by default, setting the overflow cuts them out
Try this -
<ul className="list-disc overflow-auto h-80 space-y-3 text-sm w-full sm:text-md items-start p-2">
{experience.points.map((point, i) => (
<li key={i} className='list-disc p-2'>{point}</li>
))}
</ul>
Im trying to set up my page so when you click "candidates" in the NavBar it goes to the Candidates section of the Home page (even if you're on another page). So far, I can only get it to scroll down if you click the Candidates button within the Home page using an tag but when I try to use a tag it doesn't work.
What am I doing wrong?
<nav className="w-full flex py-6 px-0 justify-between items-center navbar bg-red-gradient">
<img src={logo} alt="hoobank" className="w-[124px] h-[32px]" />
<ul className="list-none sm:flex hidden justify-end items-center flex-1 mr-5" >
{navLinks.map((nav, index) => (
<li
key={nav.id}
className={`font-poppins font-normal cursor-pointer text-[16px] mr-8 text-white `}
>
<Link to={nav.id === "home" ? "/" :`#${nav.id}`}>
<a href={`#${nav.id}`} >
{nav.title}
</a>
</Link>
</li>
))}
<Button2 />
</ul>
I've built a component that solves this problem passively in the background without having to modify any react-router Links. Works with React-Router v6.
https://github.com/ncoughlin/scroll-to-hash-element
first of all you didn't post any code. But still i think, i got your answer. Please try to check react router hashlink that will helps to move to particular section of a page.
If you still facing issue just lemme know, i will help you.
Thanks
I have tried to use React scroll parallax to get the famous scrolling effect on a couple of images which works perfectly fine in chrome, but in safari and I should say on a small screen looks jittery and give the user a bad experience.
here is a sample project created in stackBitz: https://stackblitz.com/edit/react-ybdmbn.
please guide me on how I can improve it or what I am doing wrong.
I fix the issue by removing the: speed={-10} property from the <Parallax> tag.
Parallax gets a couple of property which the speed and the translateY are basically the same thing.
<Parallax translateY={[20, -70]} >
<img src="https://picsum.photos/200/300" />
</Parallax>
<Parallax translateY={[30, -90]} >
<img src="https://picsum.photos/seed/picsum/200/300" />
</Parallax>
</div>
<div className={styles.Bottom}>
<Parallax translateY={[20, -80]} >
<img src="https://picsum.photos/200/300?grayscale" />
</Parallax>
<Parallax translateY={[40, -80]} >
<img src="https://picsum.photos/id/870/200/300?grayscale&blur=2" />
</Parallax>
</div>
hello i am facing a issue with react tailwind text area , i am tring to apply mt-5 but it is not working. When i added using style={{marginTop:"1.25rem"}} it is working , similarly properties like height margin ... are not applying to text area in react
function (){
return (
<div className=" w-24 m-5">
<input placeholder="name" className="pl-2 rounded-sm" />
<textarea className=" mt-5"></textarea>
<button className="mt-5 bg-gray-300 text-gray-800 px-2 py-1 hover:bg-black hover:text- white rounded-sm hover:underline">
submit
</button>
</div>
);
}
i actually find a problem that the react is adding a additional style to the textarea and that is overwriting the textarea, i find this is inspector, in textarea there is a additional style
how can i avoid this aditional style and who is adding it, is it tailwind or react
this was not problem with tailwind nor react , it was my browser and extensions, i removed those extensions and it is working
I'm trying to do the infamous center operation both vertical and horizontal and have sorta succeeded in doing so.
I'm trying to render a simple react component on my page that will show a 404 message. I want this message to be centered. The way I managed to do this some whitespace is leftover resulting in vertical scroll bars showing up. Ofc I could get rid of them using something like overflow-hidden, but surely there must be a way to center this message perfectly just using a better structure or certain bootstrap classes.
Here is my component:
const NotFoundPage = () => {
return (
<div>
<NavbarComp />
<div className="d-flex align-items-center justify-content-center text-center min-vh-100">
<div>
<h3 className="m-4">
<Badge variant="primary">404</Badge> Page not found...
</h3>
<Link to="/">
<Button variant="secondary">Go to main page</Button>
</Link>
</div>
</div>
</div>
);
};
In the end, I don't care that the scrollbars appear but it bothers me that this positional issue keeps occurring for me in some form or another and I wanna learn to put an end to this :)
You have already figured out how to center your "Not Found" message. What's messing it up for you is the Navbar, which you can test by taking it out. You will notice that the scroll bars disappear.
This class min-vh-100 gives the flex box below the Navbar the height of 100% of the viewport, which avoids adding any scrolls bars. The issue is that Navbar barges in and throw the page off blalance by attaching itself to the top. So the amount of srolling is exactly the height of the Navbar and since it's empty, there is very little scrolling.
An intutitive solution is to put your Navbar INSIDE the flex box. But that won't work in your case, because of how your flex box adjusts items. So I will give you a simpler solution, which should be viewed as more of a work-around.
Bootstrap does not come with classes such as min-vh-95 or min-vh-80, but luckily they are super easy to create. You can add this class to your custom CSS:
.not-found-container {
min-height: 95vh !important;
}
(or you could just stick to the naming convention and name it min-vh-95 for example)
And then change the flex box classes from:
<div className="d-flex align-items-center justify-content-center text-center min-vh-100">
to
<div className="d-flex align-items-center justify-content-center text-center not-found-container">
Here is a Sandbox to illustrate the idea: https://codesandbox.io/s/peaceful-sanne-e3m9w?file=/src/App.js
Obviously the min-height value would need to be adjusted based on the height if your Navbar.