is there anyway i can tell the margin-left to shrink based on the viewport width

meaning at first it's like 15%,but when i reach a certain breakpoint (at 768px) i switch the layout to grid-template-column:1fr instead of
grid-template-columns:[start] 4rem [start-row-2] 50% [seperator-row-1] 4rem [seperator-row-2] 50% [end-row-1] 4rem [end]
grid-template-columns:[start] 4rem [start-row-2] 50% [seperator-row-1] 4rem [seperator-row-2] 50% [end-row-1] 4rem [end]
the smaller the viewport gets; the smaller margin-left should be until it reaches to 0 like if it's a 576px it should be 5% but if it's 460px it should be 0 idk how to do that dynamically without making too many breakpoints
3 Replies
Sleep Twitch
Sleep Twitch2w ago
You could try using a combination of the max() function and the calc() where you set calc to % - x px; Like max(0px, calc(5% - 100px)). You need to use the max function to make sure it doesn't get below 0. For the margin-left property I mean
clevermissfox
clevermissfox2w ago
Just fyi, you can do math in min() and max() without having to use calcs. max(0px, 5% - 100px);
Sleep Twitch
Sleep Twitch2w ago
Oh.. even better!
Want results from more Discord servers?
Add your server