1

Image Not aligned, This is my code:

HTML:

    <li><div class="card">
        <img src="uploads/image/default_profile.jpg" width="195" height="260" />
        <p><strong>Dr./BGen. Antonio L. Tamayo</strong><br>
<strong>AFP, FPCHA, Ph. D</strong></p>
        <p>Chairman of the Board and CEO<br>
Founder, University of Perpetual Help System DALTA</p>
    </div></li>

    <li><div class="card">
        <img src="uploads/image/default_profile.jpg" width="195" height="260" />
        <p><strong>Daisy M. Tamayo</strong><br><strong>RN, MAN, Ph. D</strong></p>
        <p>Vice Chairman and Treasurer<br>
Co-Founder, University of Perpetual Help System DALTA</p>
    </div></li>

</ul>

CSS:

ul.card-wrap
padding: 0

li
    font-size: 16px
    display: inline-block

.card
    width: 195px

but when i put float: left on my CSS this happened: Image

it aligned but it got out of the container

ul.card-wrap
padding: 0

li
    float: left
    font-size: 16px
    display: inline-block

.card
    width: 195px

how can i fix this?

Hansmagz
  • 103
  • 3
  • 11

2 Answers2

1

you need clearfix with floats also float: left on the .card-wrap

.clearfix:after {
    content: "";
    display: table;
    clear: both;
}

read this clearfix

If you have the option always use flexbox

Community
  • 1
  • 1
Mehrad
  • 1,495
  • 14
  • 22
1

Add

li {
  vertical-align: top;
}

(and no float)

In your CSS, lis are defined as inline-blocks, which by default are vertically aligned to their baseline. This rule aligns them at their top.

Johannes
  • 64,305
  • 18
  • 73
  • 130