How do i get this vertical centering to work?

Hi

So i have a picture that is 100% widht and heigh of a box. On that picture i want to have another div centered both vertical and horizontal. The width on the img and its parent is dynamic so im trying to do it with the table/table-cell method, but obv im doing something wrong.

My current code, what am i doing wrong?

<div class="box">
  <img>
  <div class="table">
    <div class="table-cell">
      <div class="iconbox">
      </div>
    </div>
  </div>
</div>
.box{
width: 25%;
position: relative;
}

.img{
width: 100%;
}

.table{
display: table;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;

.table-cell{
display: table-cell;
vertical-align: middle;
height: 100%;
}

.iconbox{
height: 64px;
width: 64px;
margin: 0 auto;
background: blue;
}

Did you mean something like this:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style type="text/css">
.box {
	width: 25%;
	position: relative;
}
img { width: 100%; }
.iconbox {
	position:absolute;
	top:0;
	right:0;
	bottom:0;
	left:0;
	height: 64px;
	width: 64px;
	margin:auto;
	background: blue;
}
</style>
</head>

<body>
<div class="box"> <img src="http://placehold.it/400X400" alt="">
		<div class="iconbox">Test </div>
</div>
</body>
</html>