:root {
--offset: 30px;
}
.grid-cols-custom {
/* Calculate the column widths using custom properties and calc() */
grid-template-columns: calc((424px / (100% - var(--offset))) * 100%) calc((608px / (100% - var(--offset))) * 100%);
here in a grid I have 2 items one is 424px and other is 608px . I want them to be responsive. But padding and gap creates an visual error. so i want a percentage with a calculation :
logic : ((424px/ (full width of the div - 30px )) * 100%) so our divs will always adjust their width
please help me . Here is a problem told by css validator 'one operand must be a number'
i have been at this for 4 hours :{
I believe there is a much simpler option for you. It's responsive and basically the same sizes with a 30px gap. I think your solution is too complicated and brittle, especially to be responsive.
Your numbers:
Based on the values you're using, this is roughly a 40% to 60% ratio. Using
4fr 6frfor the columns or even better2fr 3frshould be close enough.We could get it even closer if you wanted by doing
424fr 608fr. It's odd numbers, but that would be the exact of what you're looking for. Of the total width, use 424 fractions for the first column and 608 fractions for the second. Then add the gap.