Reputation: 10305
No scripts or anything, just pure CSS and HTML.
Working in Dreamweaver and Chrome. I am having issues vertically aligning an image in the middle of a div, so I created a fiddle to post here, but the fiddle actually aligns the image vertically in the center. So a bit confused on what is going on with this. It even works here in the code snippet, but I open the file in my browser and it just doesn't work.
Here is the live example of this issue. There is no difference in code between the fiddle, the code snippet and the live form.
* {
padding: 0;
margin: 0;
border: 0;
}
.webinar-header {
background: #00A9FF;
position: relative;
overflow: hidden;
height: 75px;
line-height: 75px;
}
.webinar-header-logo {
float: left;
height: 75px;
line-height: 75px;
margin-left: 13px;
position: relative;
display: table-cell;
vertical-align:middle;
}
.webinar-header-logo img {
vertical-align: middle;
}
<div class="webinar-header">
<div class="webinar-header-logo">
<img src="http://www.metsales.com/metropolitansales/webinars/images/Metsales-webinar-lp-header.png"/>
</div>
</div>
Upvotes: 0
Views: 55
Reputation: 28349
Remove float: left
from your .webinar-header-logo
style.
There is no need for it, at least in the markup you posted
Upvotes: 2
Reputation: 3314
It's the float:left
. You're already position:relative
so you can remove your margin:left;
and float:left
.
.webinar-header-logo {
/* float: left; */
height: 75px;
line-height: 34px;
left: 45px;
position: relative;
display: table-cell;
vertical-align: middle;
}
Upvotes: 1
Reputation: 35670
It's the !DOCTYPE
on your site.
Change from:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
… to
<!DOCTYPE html>
See Vertical-align not working with XHTML 1.0 Transitional doctype?
Upvotes: 0
Reputation: 2423
There was a difference in your example and your snippet. To fix your site's code you should use display: inline-block
and height:100%
. This was answered quite well on this post:
How to vertically align an image inside div
* {
padding: 0;
margin: 0;
border: 0;
}
.webinar-header {
background: #00A9FF;
display:inline-block;
height:100%;
position: relative;
overflow: hidden;
line-height: 75px;
}
.webinar-header-logo {
float: left;
height: 75px;
display:inline-block;
line-height: 75px;
margin-left: 13px;
position: relative;
vertical-align:middle;
}
.webinar-header img {
vertical-align: middle;
display:inline-block;
height:100%;
}
<div class="webinar-header">
<img src="http://www.metsales.com/metropolitansales/webinars/images/Metsales-webinar-lp-header.png"/>
</div>
Upvotes: 0
Reputation: 1040
Try to style your div with: display: table-cell; vertical-align: middle;
Upvotes: 0