My first question on stackoverflow so if i make any mistake in making this question please comment down bellow. The tech stack i am using is comprised of node-scss, reactv16.3 and typescriptv3.7. I am making my website homepage which the current state is shown in the following image: click here to view the image
What i want to do is align the elements in the last row(when the elements dont cover the row already) to the center. My current jsx(as i am using react) for the orange gradient boxes(each orange box is a mode link) is:
import * as React from "react";
import { Link } from "react-router-dom";
import "./modeGallery.scss";
import toUrl from "../../../util/toUrl";
export interface ModeLinkProps {
modeName: string;
mainUINameOnModeClick: string;
}
const ModeLink: React.SFC<ModeLinkProps> = ({
modeName,
mainUINameOnModeClick: screenNameOnModeClick,
}) => {
const url = `${modeName}/${screenNameOnModeClick}`;
return (
<Link to={toUrl(url)}>
<h3>{modeName}</h3>
</Link>
);
};
const ModeGallery: React.FC = () => {
return (
<section className="gallery">
<ModeLink modeName="VS AI" mainUINameOnModeClick="customize" />
<ModeLink modeName="Campaign" mainUINameOnModeClick="play" />
<ModeLink modeName="Campaign" mainUINameOnModeClick="play" />
<ModeLink modeName="Campaign" mainUINameOnModeClick="play" />
<ModeLink modeName="Campaign" mainUINameOnModeClick="play" />
<ModeLink modeName="Campaign" mainUINameOnModeClick="play" />
</section>
);
};
export default ModeGallery;
Please note that i only have so many equal boxes to test if the layout system would work if i needed more than the ones i need now. So delleting those boxes is not a solution. My scss for this component is:
@import "../base-variables/baseScreenSizes";
@import "../base-mixins/gradients";
$boxWidth: calc(180px + 5vw);
$boxShadowOffset: 10px;
section.gallery {
display: grid;
padding: 2em;
color: white;
grid-template-columns: repeat(auto-fill, minmax($boxWidth, 1fr));
grid-auto-rows: calc(10rem + 5vw);
column-gap: 5rem;
row-gap: 2rem;
justify-content: space-around;
> a {
padding: 0.8em;
border-radius: 20px;
box-shadow: -$boxShadowOffset $boxShadowOffset 16px red;
@include animatedLinearGradient($orangeCoralGradient, 3s);
h3 {
font-family: cursive;
font-size: 1.35rem;
margin-top: 0;
}
}
}
I am using here the grid system because of the amazing responsivness it gives so changing to something like flexbox is also not an option.
The answer that has been proposed as a possible duplicate doesn't work for me as it only provides one solution using the css grid and that solution doesn't work for me.
So what can i do to align the elements in the last row to the center(while also keeping the gap between them)?