the style changes(button with number) only visually when I scale the page (zoom in, zoom out) . But I don’t have any @media
enter image description here
My code button with number(without state, I removed them in this code)
export default function InfoButton({ click, row, col, children }) {
let cssBtn =
"flex justify-center items-center relative before:absolute before:-top-[40%] before:left-1/2 before:-translate-x-1/2 before:text-black before:text-2xl aspect-square";
if (styles) {
cssBtn += " before:content-['x'] text-stone-400";
}
return (
<button
className={cssBtn}
onClick={handleCloseNumber}
>
{children}
</button>
);
}
Block for buttons (also without state, I removed them in this code)
export default function InfoField({ direction, infoTabs }) {
const cssClasses = {
mainDiv: "flex",
row: "text-end flex-1 border border-stone-400",
};
let index
if (direction === "vertical") {
cssClasses.mainDiv += " flex-row w-full";
cssClasses.row += " flex flex-col justify-end";
index = selectedCol;
} else {
cssClasses.mainDiv += " flex-col w-full";
cssClasses.row += " flex flex-row justify-end";
index = selectedRow;
}
function getCorrectStyle(indexRow) {
let css = cssClasses.row;
if (direction === "vertical") {
if ((indexRow + 1) % 5 === 0) {
css += " border-r-black";
} else if (indexRow % 5 === 0) {
css += " border-l-black";
}
} else {
if ((indexRow + 1) % 5 === 0) {
css += " border-b-black";
} else if (indexRow % 5 === 0) {
css += " border-t-black";
}
}
return css;
}
return (
<div className={cssClasses.mainDiv}>
{infoTabs.map((row, rowIndex) => {
let css = getCorrectStyle(rowIndex);
if(index == rowIndex && index){
css += ' bg-orange-300'
}
else{
css += ' bg-amber-200'
}
return (
<div className={css} key={rowIndex}>
{row.length === 0 ? (
<InfoButton key={rowIndex + "1"} row={rowIndex} />
) : undefined}
{row.map((cell, cellIndex) => {
return (
<InfoButton
click={() => {
handleCompleteRow(rowIndex, cellIndex);
}}
key={cellIndex}
row={rowIndex}
col={cellIndex}
>
{cell}
</InfoButton>
);
})}
</div>
);
})}
</div>
);
}
My main component
export default function GameField({ emptyRow, emptyCol }) {
return (
<FocusCellContext.Provider value={focusCellCxt}>
<div className="">
<section
id="table"
className="grid grid-cols-[1fr_3fr_1fr] grid-rows-[1fr_3fr_1fr]"
onMouseMove={(e) => handleMove(e)}
>
<Table scale={10} info={true} />
<InfoField direction="vertical" infoTabs={infoLineVertical} />
<div></div>
<InfoField direction="horizontal" infoTabs={infoLineHorizontal} />
<Table emptyCol={emptyCol} emptyRow={emptyRow} />
<InfoField direction="horizontal" infoTabs={infoLineHorizontal} />
<div></div>
<InfoField direction="vertical" infoTabs={infoLineVertical} />
</section>
</div>
</FocusCellContext.Provider>
);
}
I tried to set min-width, it works, but I don’t want to manually write this width