Chrislizardc
Chrislizardc
KPCKevin Powell - Community
Created by Chrislizardc on 10/11/2024 in #front-end
CH vs PX for container queries
Hey all what is your opinion on using ch units for mobile responsiveness for example
@container carousel-container (max-width: 100ch)
@container carousel-container (max-width: 100ch)
Or is pixels betteer for width in your opinion. I have seen @Kevin Powell use ch for making mobile responsivenes containers, but isn't it clunky?
18 replies
KPCKevin Powell - Community
Created by Chrislizardc on 10/1/2024 in #front-end
Dealing with pseudo elements and background color
No description
3 replies
KPCKevin Powell - Community
Created by Chrislizardc on 9/19/2024 in #front-end
How to Make a Responsive and Reusable Flexbox Component for Different Number of Boxes?
Hey everyone, I’m working on a component that uses display: flex . Currently, I have 3 boxes that are working fine, and they adjust nicely when resized. However, I want this component to be reusable in other places where I might want 4 boxes, or even just 2 boxes, without having to rewrite the code. My goal is to make the component flexible enough so that I can reuse it for any number of boxes (2, 3, or 4 boxes) . Is that possible?
flynt-component[name='HeadingBoxes'] {
background-color: var(--background-color);
margin-block-start: 0;
padding-block: clamp(5rem, 16vw, 10rem);
padding-inline: var(--container-spacing);

.heading {
text-align: center;
}

.flexContainer {
display: flex;
gap: 1em;
flex-wrap: wrap;

.box {
background-color: var(--box-background-color);
border-radius: 16px;
box-shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.1);
box-sizing: border-box;
flex: 1;
max-width: 100%;
color: var(--color-primary-white);
padding: clamp(1.5rem, 4vw, 2.5rem);
text-align: center;
transition: all 0.3s ease;

&:hover {
box-shadow: 0 0.375rem 0.75rem rgba(0, 0, 0, 0.15);
transform: translateY(-0.3125rem);
}

.icon {
background-color: var(--color-blue-10);
border-radius: 50%;
inline-size: clamp(3.4375rem, 8vw, 4.0625rem);
margin-block-end: clamp(0.75rem, 2vw, 1.25rem);
padding: clamp(0.5rem, 1.5vw, 0.9375rem);
}

a {
color: var(--color-accent);
font-size: var(--font-size-body-small);
padding-block: clamp(0.5rem, 1.5vw, 0.625rem);
padding-inline: clamp(1rem, 3vw, 1.25rem);
text-decoration: none;
transition: all 0.3s ease;

&:hover,
&:focus,
&:active {
text-decoration: underline;
}
}
}
}

.paragraph {
margin-block-end: clamp(2.5rem, 8vw, 5rem);
text-align: center;
}
}
flynt-component[name='HeadingBoxes'] {
background-color: var(--background-color);
margin-block-start: 0;
padding-block: clamp(5rem, 16vw, 10rem);
padding-inline: var(--container-spacing);

.heading {
text-align: center;
}

.flexContainer {
display: flex;
gap: 1em;
flex-wrap: wrap;

.box {
background-color: var(--box-background-color);
border-radius: 16px;
box-shadow: 0 0.25rem 0.375rem rgba(0, 0, 0, 0.1);
box-sizing: border-box;
flex: 1;
max-width: 100%;
color: var(--color-primary-white);
padding: clamp(1.5rem, 4vw, 2.5rem);
text-align: center;
transition: all 0.3s ease;

&:hover {
box-shadow: 0 0.375rem 0.75rem rgba(0, 0, 0, 0.15);
transform: translateY(-0.3125rem);
}

.icon {
background-color: var(--color-blue-10);
border-radius: 50%;
inline-size: clamp(3.4375rem, 8vw, 4.0625rem);
margin-block-end: clamp(0.75rem, 2vw, 1.25rem);
padding: clamp(0.5rem, 1.5vw, 0.9375rem);
}

a {
color: var(--color-accent);
font-size: var(--font-size-body-small);
padding-block: clamp(0.5rem, 1.5vw, 0.625rem);
padding-inline: clamp(1rem, 3vw, 1.25rem);
text-decoration: none;
transition: all 0.3s ease;

&:hover,
&:focus,
&:active {
text-decoration: underline;
}
}
}
}

.paragraph {
margin-block-end: clamp(2.5rem, 8vw, 5rem);
text-align: center;
}
}
7 replies
KPCKevin Powell - Community
Created by Chrislizardc on 9/12/2024 in #front-end
Container query not working
Hello, my container query on .gridContainer is not working at all. If i change it to @media it works fine and dandy but the moment i try to use @container it just breaks and doesnt create me a 4 column layout on desktop as it should :
@use "sass:math";

@function rem($pixels) {
@return math.div($pixels, 16) * 1rem;
}

flynt-component[name='HeadingBoxesParagraph'] {
background-color: var(--color-blue-10);
margin-block-start: 0;
padding-block: clamp(rem(80), 16vw, rem(160));
padding-inline: var(--container-spacing);

.heading {
text-align: center;
}

.gridContainer {
container-name: grid-test;
container-type: inline-size;
display: grid;
gap: clamp(rem(16), 4vw, rem(32));
grid-template-columns: repeat(2, 1fr);
justify-content: center;
margin-block: 0;
margin-block-start: 10px;
max-inline-size: rem(1400);
padding-block: clamp(rem(32), 6vw, rem(64));
padding-inline: rem(16);

@container grid-test (width > calc(40ch * 4)) {
grid-template-columns: repeat(4, 1fr);
}

.box {
align-items: center;
background-color: var(--color-background, #fff);
block-size: 100%;
border-radius: rem(15);
box-shadow: 0 rem(4) rem(6) rgba(0, 0, 0, 0.1);
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: clamp(rem(24), 4vw, rem(40));
text-align: center;
transition: all 0.3s ease;

&:hover {
box-shadow: 0 rem(6) rem(12) rgba(0, 0, 0, 0.15);
transform: translateY(rem(-5));
}
}
}
}
@use "sass:math";

@function rem($pixels) {
@return math.div($pixels, 16) * 1rem;
}

flynt-component[name='HeadingBoxesParagraph'] {
background-color: var(--color-blue-10);
margin-block-start: 0;
padding-block: clamp(rem(80), 16vw, rem(160));
padding-inline: var(--container-spacing);

.heading {
text-align: center;
}

.gridContainer {
container-name: grid-test;
container-type: inline-size;
display: grid;
gap: clamp(rem(16), 4vw, rem(32));
grid-template-columns: repeat(2, 1fr);
justify-content: center;
margin-block: 0;
margin-block-start: 10px;
max-inline-size: rem(1400);
padding-block: clamp(rem(32), 6vw, rem(64));
padding-inline: rem(16);

@container grid-test (width > calc(40ch * 4)) {
grid-template-columns: repeat(4, 1fr);
}

.box {
align-items: center;
background-color: var(--color-background, #fff);
block-size: 100%;
border-radius: rem(15);
box-shadow: 0 rem(4) rem(6) rgba(0, 0, 0, 0.1);
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
padding: clamp(rem(24), 4vw, rem(40));
text-align: center;
transition: all 0.3s ease;

&:hover {
box-shadow: 0 rem(6) rem(12) rgba(0, 0, 0, 0.15);
transform: translateY(rem(-5));
}
}
}
}
4 replies