view raw
C.Ronaldo C.Ronaldo - 10 months ago 34
CSS Question

How to vertical center floated div with anchor and image

I want to center my images inside a div that is floated. I've tried

but that wasn't a success. I guess that's because it's floated.

I've created a jfiddle about my problem:


you may use vertical-align on img and line-height, example:

.top {
  height: 150px;
  background-color: blue;

.container {
  float: right;
  line-height: 150px;

img {
  vertical-align: middle;
<div class="top">
  <div class="container">
    <a href="#">
      <img src="" alt="Smiley face" height="50" width="140">