Semantic vertical centering

Developer
Size
2,394 Kb
Views
26,312

How do I make an semantic vertical centering?

This is a demonstration of a semantic vertical centering technique for elements of unknown size as posted by Chris Coyier at CSS Tricks and pioneered by Michał Czernow. I take no credit for any of this, I merely documented the technique.. What is a semantic vertical centering? How do you make a semantic vertical centering? This script and codes were developed by Niels Oeltjen on 08 September 2022, Thursday.

Semantic vertical centering Previews

Semantic vertical centering - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Semantic vertical centering</title> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> <link rel="stylesheet" href="css/style.css">
</head>
<body> <!-- From here: https://css-tricks.com/centering-in-the-unknown/ -->
<div class="block"> <div class="centered"> <h1>This white box is vertically centered</h1> <p>This is a demonstration of a semantic vertical centering technique for elements of unknown size as posted by Chris Coyier at <a href="https://css-tricks.com/centering-in-the-unknown/" target="_blank">CSS Tricks</a> and pioneered by Michał Czernow. I take no credit for any of this, I merely documented the technique.</p> <p><a href="https://codepen.io/Elbone/full/HdqGh" target="_blank">Click here</a> to open in fullscreen mode (more realistic)</p> </div>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
</body>
</html>

Semantic vertical centering - Script Codes CSS Codes

/* From here: https://css-tricks.com/centering-in-the-unknown/ */
/* This parent can be any width and height */
.block { text-align: center;
}
/* The ghost, nudged to maintain perfect centering */
.block:before { content: ''; display: inline-block; height: 100%; vertical-align: middle; margin-right: -0.25em; /* Adjusts for spacing */
}
/* The element to be centered, can also be of any width and height */
.centered { display: inline-block; vertical-align: middle;
}
/* Presentation styling*/
body, html, .block { height: 100%;
}
.block { background: #ffff00;
}
.centered { background: #fff; border: 3px double; outline: 5px solid #fff; max-width: 30em; margin: 1em;
}
body { color: #826037;
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif; line-height: 1.275em;
}
h1 { font-style: italic; font-size: 1.2em; border-bottom: 1px solid; padding: 1em;
}
p { padding: 1em;
}
a { color: #ff0000; text-decoration: none;
}
Semantic vertical centering - Script Codes
Semantic vertical centering - Script Codes
Home Page Home
Developer Niels Oeltjen
Username NielsOeltjen
Uploaded September 08, 2022
Rating 4.5
Size 2,394 Kb
Views 26,312
Do you need developer help for Semantic vertical centering?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Niels Oeltjen (NielsOeltjen) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!