Here the demo: https://codesandbox.io/s/priceless-cloud-ommr5
I would my text to go to the center of the div preserving on the way its left alignment.
I have tried:
- margin:auto,
- flexbox with center justification,
- x-centering on absolute positioning: all theses methods fails.
How can I align my text and preserving the right justification of the text by the way, as in the following image?:
Here the ReactJS' snippet:
import React from "react";
import "./styles.css";
export default function App() {
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<div className="align_text">
<h2>Start editing to see some magic happen!</h2>
</div>
</div>
);
}
Here the CSS' snippet:
.App {
font-family: sans-serif;
}
h2 {
width:100vw;
margin:auto;
position: absolute;
left: 50%;
transform: translate(-50%, 0);
display:flex;
justify-content: center;
align-items: center;
background:orange;
}
.align_text{
position:relative;
width:100vw;
display:flex;
justify-content: center;
align-items: center;
}
