text-align: center;
vertical-align: middle;
line-height: 90px; /* The same as your div height */
#container {
display: flex;
justify-content: center;
align-items: center;
}
/* 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 */
.contentCentralized {
width: 100%;
height : 200px; //Remove height if you don't want specified height for it
display: flex;
flex-direction: column; //options : row | row-reverse | column | column-reverse
flex-wrap: wrap; //options : flex-start | flex-end | center | baseline | stretch
justify-content: center; //options : start | center | space-between | space-around | space-evenly
align-items: center;
}
<div class="contentCentralized">
<h3>Hello Developers.</h3>
</div>
html, body {
height: 100%;
}
.parent {
width: 100%;
height: 100%;
display: table;
text-align: center;
}
.parent > .child {
display: table-cell;
vertical-align: middle;
}
text-align: center
.center {
border: 5px solid #FFFF00;
text-align: center;
}
It's okay bro use text-align: center; or justify-content with flexbox it's a lifesaver
Code Example |
---|
Css :: secondline ellipsis |
Css :: multiple values in @media |
Css :: css hiddden |
Css :: remve arrow from input ype number |
Css :: css hide timeline |
Css :: align div to center of screen |
Css :: how to add inline class to a paragraph in css |
Css :: change scrollbar color |
Css :: border color css |
Css :: css clearfix |
Css :: apply style to second child div |
Css :: css super smooth shadow |
Css :: @font-face multiple font weights |
Css :: reset id sequence postgres |
Css :: css orange color |
Css :: css transform border radius |
Css :: css clip text |
Css :: css text properties |
Css :: make element float on top |
Css :: css select none |
Css :: set svg background color css |
Css :: video camera icon font awesome |
Css :: nth last of type |
Css :: putting picture shaddow in css |
Css :: css text |
Css :: background image overlay |
Css :: cool box shadow effects css |
Css :: css user-select |
Css :: css mobile height 100vh |
Css :: justify center wont wotk with max-width css |