CSS-Centered (Horizontal and Vertical)
Centered (Horizontal and Vertical) Method 1: transform Method 2: flex
by JSDavi
HTML
<h3>
Centered (Horizontal and Vertical)
</h3>
<h4>
Method 1: use transform
</h4>
<div class="contain">
<div class="wrap">So you just bought your first font and some of the characters look different than the samples. The culprit is probably Open-type features. Software often vary in what they have turned on by default. </div>
</div>
<h4>
Method 2: use flex
</h4>
<div class="contain1">
<div class="wrap1">So you just bought your first font and some of the characters look different than the samples. The culprit is probably Open-type features. Software often vary in what they have turned on by default. </div>
</div>
CSS
[class *=col-] {
background-color: #eee;
border: 1px solid #ccc;
}
.scrollspy-example {
height: 200px;
font-size: 20px;
overflow: auto;
}
.wrap {
position: absolute;
top: 50%;
left: 50%;
width: 85%;
padding: 5%;
transform: translate(-50%, -50%);
text-align: center;
background: #393;
}
.contain {
height: 150px;
width: 90%;
background-color: red;
position: relative;
}
.contain1 {
width: 80%;
display: flex;
justify-content: center;
align-items: center;
background-color: red;
padding: 5%;
}
.wrap1 {
padding: 20px;
text-align: center;
background: #393;
}