You really should move your CSS out of the style
attribute and into a file like style.css
if you have not done so. But if you really have to you can place the code below into inline styles like you have now.
Remove the align="left"
attribute from your image tag and set the image's display to block
. This will allow margin: 0 auto;
to center your image for you inside the containing DIV.
Looks like you'll have to replicate a <table>
with CSS to get the vertical centering you desire. Table cells allow vertical centering. To do this I've added and additional DIV with a class of .container
. The .container
DIV has it's display set to table
and the .image-container
DIV, which is acting like a table cell, has it's display set to table-cell
.
CSS
.container {
float: left;
width: 80px;
height: 80px;
padding: 8px;
border: 1px solid #ccc;
display: table;
}
.image-container {
display: table-cell;
vertical-align: middle;
}
.image-container img {
display: block;
margin: 0 auto;
}
HTML
<div class="container">
<div class="image-container">
<img src="images/logo/logo1.jpg">
</div>
</div>
JSFiddle: http://jsfiddle.net/MJ5j4/