I have 2 instances of images with text that need to resize to the same amount as related text, which have been set in ems. One is a logotype in a navigational menu, as a foreground image and one is a unique headline that have been font-replaced in the old-fashioned way of a background image and negative text-indent.
In Firefox and Chrome at least, setting the proper em size for the height gives the correct behavior. I'm not setting the width to avoid perspective issues.
In Safari, as late as 5.1.7, however, the image is shown too big. Any suggestions or thoughts for steps towards a solution here? I haven't tested IE yet, but I am supplying specific styles for 7, 8 and 9.
I'd prefer resizing working also when user is zooming text only. The end objective is to have the image resize in the exact same amount as the text does, as the image text sixe matches the real text.
HTML5:
ul id="one" class="nav">
<!--Logotype-->
<li class="logo"> <a href="/">
<h1><img src="http://bitly.com/YV6G0S"></h1>
</a></li>
<!-- endLogotype -->
<li><a href="#">Text Link 2</a></li>
<li><a href="#">Text Link 3</a></li>
</ul>
CSS:
body {
font: 81.25% Arial;
}
.nav {
list-style: none;
height: 100%;
}
.nav li {
float: left;
font-size: 2em;
}
.nav li a {
display: inline-block;
width: 100%;
text-align: center;
padding: 0.5em 0.4em;
}
.nav li a h1 {
display: inline-block;
font-size: 1em;
font-weight: normal;
}
.logo img {
height: 1em;
}
I've updated the example with reworked code with a shortened version of the jsfiddle-example. (Make some horizontal room to view the result) to better illustrate the objective how I want the graphic to behave. In the fiddle the graphic is just a screen dump of the text cut to 26 pixels height and set to the height of 2em. The root em is then typically 13px.
In the example you can see that the graphic actually is resizing in Firefox, which is hopeful. However an image isn't text so some adjustments have to be made to make the graphic sit at the same spot and behave like the sibling text links.
In the real world the graphic isn't the same size and look and would need some offsets to sit right with the text. But when resizing the page the graphic would resize like the text.