Skip to content

Instantly share code, notes, and snippets.

@tomcam
Last active January 3, 2024 05:56
Show Gist options
  • Save tomcam/4dd6dfb90abdc504daccd9a8003329a3 to your computer and use it in GitHub Desktop.
Save tomcam/4dd6dfb90abdc504daccd9a8003329a3 to your computer and use it in GitHub Desktop.
How should I center vertically with spectre.css?
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Center test 1 | Spectre.css</title>
<link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
<style>
<!-- NOT NECESSARY! JUST USE .flex-centered. See comment by @Prid13 at https://gist.github.com/tomcam/4dd6dfb90abdc504daccd9a8003329a3?permalink_comment_id=4815360#gistcomment-4815360 -->
.vcenter {
text-align: center;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translateX(-50%) translateY(-50%);
transform: translateX(-50%) translateY(-50%);
}
</style>
</head>
<body>
<div class="container">
<div class="columns">
<div class="column vcenter">
<h1>CENTERED</h1>
</div>
</div>
</div>
</body>
@Prid13
Copy link

Prid13 commented Jan 2, 2024

For future reference: .flex-centered

@tomcam
Copy link
Author

tomcam commented Jan 2, 2024

Thank you so much, @Prid13!

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