Skip to content

Instantly share code, notes, and snippets.

@justin-lyon
Created May 8, 2021 02:29
Show Gist options
  • Save justin-lyon/f55b8366acc8de5de23de5207fc937ec to your computer and use it in GitHub Desktop.
Save justin-lyon/f55b8366acc8de5de23de5207fc937ec to your computer and use it in GitHub Desktop.
align center using flex
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html,
body {
margin: 0;
padding: 0;
font-size: 10px;
line-height: 1.1rem;
}
.container {
margin: 0 10vh;
}
.grid {
display: flex;
justify-content: center;
}
.box {
/* the Boxes are just a visual aid */
height: 3.1rem;
width: 4rem;
background-color: yellow;
}
</style>
</head>
<body>
<div class="container">
<div class="grid">
<div class="box"></div>
<div>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Architecto recusandae sequi eligendi sapiente temporibus, quasi nostrum enim laboriosam ullam ab.
</p>
</div>
<div class="box"></div>
</div>
</div>
</body>
</html>
@justin-lyon
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment