I have a banner component inside of a div
using CSS grid and I can't figure out how to vertically center the text. Right now, I can horizontally center it but it is align to the top of the div. I know CSS grid makes vertical-align
not work so I tried align-self
, place-self
and justify-self
but none of those worked either. All of the other threads seem to suggest those were solutions. Here is the code:
import React from 'react';
import './Banner.css';
const Banner = () => {
return (
<div className="banner-cont">
<h1>Title</h1>
</div>
);
};
export default Banner;
.banner-cont {
height: 120px;
width: 100%;
grid-column: 1 / span 2;
background-color: #0193fd;
box-sizing: border-box;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.5);
border-radius: 20px;
}
.banner-cont h1 {
color: white;
text-align: center;
align-self: center;
justify-self: center;
place-self: center;
}