Using CSS to center text vertically and horizontally

http://scripting.com/2014/08/12/howToCenterOneObjectInsideAnother.html

http://css-tricks.com/centering-in-the-unknown/

<html>
<head>
<style>
.divContainer {
display: table;
width: 100%;
height: 100%;
}
.divCenteredObject {
display: table-cell;
vertical-align: middle;
text-align: center;
}
</style>
</head>
<body>
<div class="divContainer">
<div class="divCenteredObject">
<h1>This text is centered, both vertically and horizontally.</h1>
</div>
</div>
</body>
</html>

#css - #howto

From JR's : articles
45 words - 460 chars
created on
updated on - #
source - versions

Related articles
Centering multiple div blocks in a responsive manner - Mar 12, 2015



A     A     A     A     A

© 2013-2017 JotHut - Online notebook

current date: Apr 25, 2024 - 9:30 a.m. EDT