Center a div css
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
Puzzled Penguin
.center {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.parent {
position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
center{
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
/* Assume the div has a class of "center"
The below would center it horizontally
*/
.center {
margin-left: auto;
margin-right: auto;
}
/* There is a shorthand and it is given below */
.center {
margin: 0 auto;
}
.center{
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
EntireBanner: {
position: "relative",
backgroundImage: `url(${bgImage})`,
backgroundSize: "cover",
backgroundRepeat: "no-repeat",
width: "100%",
height: "800px",
},
textBox: {
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
},