Imagen del centro CSS
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
Unusual Unicorn
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
.parent {
display: flex;
justify-content: center;
align-items: center;
}
<div style="text-align:center">Dieser Text wird zentriert.
<p>Ebenso dieser Paragraph.</p></div>
/* For horizontal align: */
parent-element {text-align:center;}
/* For horizontal and vertical align: */
parent-element {position: relative;}
element-to-be-centered {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
/* See https://www.w3schools.com/css/css_align.asp for more info */
<style>
body { background: white }
section {
background: black;
color: white;
border-radius: 1em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%)
}
</style>
<section>
<h1>Nicely centered</h1>
<p>This text block is vertically centered.
<p>Horizontally, too, if the window is wide enough.
</section>
.someClass {
display: flex;
align-items: center;
justify-content: center;
}