Kevin Powell - Community

KPC

Kevin Powell - Community

A friendly place for developers to meet other devs, ask questions, get help, and just have a good time šŸ™‚.

Join

front-end

resources

back-end

ui-ux

os-and-tools

Best use cases for the "lh" unit

Hey, i was wondering what the best use cases for the lh unit are, i see a lot of people use it for spacing and for icon sizes like in this example (https://codepen.io/piccalilli/pen/OJdYxRv), i'd appreciate any insight, thanks in advance.

Issue with JQuery event handler

Hello. I'm animating a navbar which responds to mouse and keyboard events using JQuery event handlers to ensure a proper UX. Most part is done, however there remains one last issue where clicking/focusing on a link and un-hovering right after, the "highlighter element" returns back to its initial location. https://codepen.io/Suggon/pen/MWzqByj?editors=0010 The highligher is a live element conrolled by JS. In order to animate moving towards the target, I used the .on('mouseenter focusin', function() method which is working nicely. Out of intuition, I also used .on('mouseleave focusout', function() for its "reverse" - that's the one which did not work. The apparent reason being that it's listening to EITHER mouseleave OR focusout. So assuming we clicked on a link to gain a focus state, the highlighter doesn't retain itself, since the mouseleave event is fired despite the element being still on focus state....

variables inside the function and order of Precedence in JS

The variable fahrenheit has function scope i understand but it is still not declared (as a let or const )but works why so?? function convertToFahrenheit(celsius) { fahrenheit = (celsius*9/5)+32; return fahrenheit;...

Mystery spacing between 2 flex rows

Minimal reproducible code: https://codepen.io/ifigoinimightdie/pen/xxNeYxg I have a simple flexbox with flex-wrap: wrap. My 1st flex child has width: 100%, so the 2nd flex child goes to a new row. Yet there's a TON of extra spacing between them that has nothing to do with padding and margin. I never set a row-gap either. Inspector indicates a purple region, which I think means the "shrink/grow" area. I tried setting flex: 1 etc. nothing has worked. Full codepen here: ...
No description

vertically position floated element

https://codepen.io/sos909/pen/XWwQZpN how can i make the a element appear at the bottom line of the div not the top while staying on the right

Can't center title - horizontally + vertically

Current result - image 1 Desired result - image 2 Code, HTML: ...
No description

Override Default Border on Input

I am working on the tip calculator project on frontendmentor and I've used :hover, :focus and :active to adjust the border color of the custom tip input box but it still defaults to the blue border when I start typing in both chrome and firefox. Here is my deployed project so far: https://calculate-and-split-tip.netlify.app/ My codebase is here: https://github.com/mathematiCode/Tip-Calculator-FEM I've tried commenting out all of my js, in devtools it shows that the styles in the :focus, :hover selector are being applied but it keeps changing the color to the default blue when I start typing. ...

Not getting informations from a form

I am using web3forms in order to get infro from a form to my gmial but insted of getting the info, i get a blank email, so if anyone knows how can i do this a different way, or what i did wrong would be ameazing thank you...
No description

Calculation of hypothetical main size and flex base size with paddings

So i was reading this article by kevin : https://css-tricks.com/equal-columns-with-flexbox-its-more-complicated-than-you-might-think/#:~:text=always%20the%20case%E2%80%A6-,The,-reason%20for%20this Now he mentions 2 ways to make equal columns and 2 problems with it. First, using flex:1, he mentions that since content-size of all items is 0, we only have 600-32 = 568px to distribute cuz of the padding on the middle element. So, after the padding is added back, middle element is wider. And padding isn't included in that flex-basis even though we used border-box In the 2nd case, using flex-basis: 100%, he mentions that now the padding is included in the flex-basis and now the content-size of the middle item is 600-32 = 568px and of the others is 600px only. So, the middle one shrinks slightly less....

API returning error and also CORS error

I am trying to use this API, which I found on the website https://random-word-api.herokuapp.com/. The objective is to return a random word for my wordle game. The problem is that it is not returning the grid anymore, when I try to click in any of the options it returns some errors on the console, as shown in the image below. I spotted that the undefined error happens probably because there is no word to generate the grids. I found it weird that it is returning a CORS error, for being backend stu...
No description

margin-top and flow utility clash

Hey, i'd like to align the buttons to the end of the cards. I have the elements within the cards spaced out with a flow utility class which uses margin-top. Setting the flow-space on the buttons to auto does what i'd like however removes the space between the paragraph and button on the card holding the most content (and certain cards when the grid items start stacking when the viewport shrinks) due to the way auto behaves and the fact it's overriding the default property in the utility of course. I can't set this on just the first two cards in the example as i'm looking for a more flexible solution as you may not know which card has the most content or how many cards there could be. So from this i have two questions. 1. What sort of workaround/fix could i do here? 2. Why must the container (in this case .card) have to be a flex container for margin-top: auto; to work? If i remove it it stops working. ...

Parent container with child elements position: absolute does not size properly to fit the children

Really hard to put my thoughts into words but I have a container essentially and I have two h3's inside of it which I want to paginate. I have it working as I want but only when I explicitly tell the container its height and width. I understand its behavior because position absolute pulls it out of the flow but that means without explicit width and height my container is a tiny blob. This impacts my reactiveness of the website as when the width of the device increases or decreases text starts to overflow instead of the container adapting to fit the content If I remove position absolute and try to explicitly set the width of the child it doesn't work (I try set 1200px) css:...

Positioning within a grid

Just wondering how people position elements within css-grid cols/rows? I know you can align or justify elements, but I'm talking about more fine-grained than that. Say you want to start an element 'x' amount down from its starting row. For example the element in the above image spans 3 rows and is vertically centered, but I think it would look better positioned 10% down from its starting row I could use mt-[10%] on the element to have something a bit more reponsive to the page height, have a nested element with another grid covering all 3 rows, or something more silly, like using flex and a flex-basis of 90% and pushing the content to the end....
No description

I want to create an effect and i dont know how

I'm asking this question without any knowledge in code (Doing only a bit of CSS here an there). I'm a graphic designer who try to learn coding. The effect: So I was wondering how can create the effect in this container: ...

CSS list-style-type not being applied on <details><summary> on safari

Hey everyone, I'm actually using tailwind but have tried it with css and the behavior is the same: ```html <details class="group list-none before:hidden"> <summary class="cursor-pointer list-none text-xl">...
No description

How can I make the handle which resizes content bigger. It's too small.

I set my parent up with this CSS but the handle that appears is so tiny that it's barely visible.
resize: both;
overflow: auto;
resize: both;
overflow: auto;
...
No description

Problem with transition height

Hi guys, I'm trying to hide the tabs on scroll down and show on scroll up but I'm facing this problem. Can anyone help me? I'm using MUI and this is how I toggle the height. ```ts <Box sx={{ display: "grid",...

Need Help identifying different Semantic Sections

In the picture I provided is that entire piece supposed to be all in the header or the logo and button in the header and the content below it a section? And to add to that is the header section mostly for navigation and titles or can there be just regular content in there?...
No description

justify-self and align-self flexbox?

Do justify-self and align-self not work for elements in a flexbox container? Iā€™m finding mixed info and some of it is 8 years old.

prefers-reduced-motion is a text color animation ok?

I'm making a text-based browser game and I just added a Wating for player to join indicator when you join the room and it has a wave animation, but I'd also like to take into consideration users with prefers-reduced-motion setting on so I made an alternative for it, where text "shines" through. I'm not sure if it's a good alternative or if it's still too much for users who prefer reduced motion, does anybody know anything about it? First gif is original, second is reduced motion version...
No description