1

I want to align vertically list items inside a div, this what I code :

<div>
 <div class="span4">
  <img style="float: left; width: 80px;" src="http://www.zalfaniyamen.com/wp-content/uploads/2020/02/200px-Dhofar_Club.png" />
 </div>
 <div>
  <ul class="list-group" style="margin-bottom: 0 !important;">
    <li class="list-group-item active" style="margin-left: 120px !important; padding-top: 0 !important; padding-bottom: 0 !important; font-size: 20px; font-weight: 600; width: 60%;">
    Win super cup of sultun
    </li>
  </ul>
 </div>
</div>
<div>
<div style="clear: both;"></div>
</div>
Somangshu Goswami
  • 1,098
  • 11
  • 27
547n00n
  • 1,356
  • 6
  • 30
  • 55
  • Can you elaborate more? How do you align vertically list items inside div because by default list items are aligned vertically. – Sourav Singh Feb 03 '20 at 05:14

2 Answers2

1

Can you please check with the below code hope it will resolve your query.

<div>
<div class="span4" style="vertical-align: middle;
display: inline-block;">
<img style="width: 80px;" src="http://www.zalfaniyamen.com/wp-content/uploads/2020/02/200px-Dhofar_Club.png" />
</div>
<div style="vertical-align: middle;
display: inline-block;">
<ul class="list-group" style="margin: 0;">
<li class="list-group-item active" style="margin-left: 120px !important; padding-top: 0 !important; padding-bottom: 0 !important; font-size: 20px; font-weight: 600; ">
Win super cup of sultun
</li>
</ul>
</div>
</div>
<div>
<div style="clear: both;"></div>
</div>
Yudiz Solutions
  • 4,216
  • 2
  • 7
  • 21
0

You can use display: flex to align it middle.

.parentDiv {
  display: flex;
}
.span4 img {
  float: left; 
  width: 80px;
}

ul {
  margin-bottom: 0;
}

li {
  margin-left: 100px;
  padding-top: 0; 
  padding-bottom: 0; 
  font-size: 20px; 
  font-weight: 600;
}
<div class="parentDiv">
 <div class="span4">
  <img src="http://www.zalfaniyamen.com/wp-content/uploads/2020/02/200px-Dhofar_Club.png" />
 </div>
 <div>
  <ul class="list-group">
    <li class="list-group-item active">
    Win super cup of sultun
    </li>
  </ul>
 </div>
</div>

for more detail you can refer 'vertical align'

Super User
  • 9,448
  • 3
  • 31
  • 47