Đặng Duy Tâm Đặng Duy Tâm - 1 month ago 22
HTML Question

CSS text on the middle of div (div height:20%)

<style>
._1{
height:20%;
width:100%;
overflow:hidden;
white-space:nowrap;
text-overflow:ellipsis;
}
</style>
<div class="_1">content</div>


how to make content align at the middle of the div?
thanks.
demo

Edit: Height is % not px. I set
line-height: 20%
but it's not work.

Answer
   div{ 
    height: 20%;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: space-around;
    align-content: center;    
  }