我使用CSS定位帶有圖像的文本時出現問題。它適用於Firefox和IE,但不適用於Safari。圖像放置在文本的左側,我希望文本在垂直定位中位於圖像的中央。我正在使用font-face使用自定義字體(MyriadProLight)。使用CSS的文本和圖像定位
這是它的外觀在Safari: http://oi52.tinypic.com/2eg5p8x.jpg
這是我想它(和它的外觀在Firefox和IE): http://oi54.tinypic.com/1zg3xhx.jpg
HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Title</title>
<style>
@font-face {
font-family: 'MyriadProLight';
src: url('myriadpro-light-webfont.eot');
src: local('☺'), url('myriadpro-light-webfont.woff') format('woff'), url('myriadpro-light-webfont.ttf') format('truetype'), url('myriadpro-light-webfont.svg#webfontpR0gSEvM') format('svg');
font-weight: normal;
font-style: normal;
}
h1
{
font-size: 20pt;
font-family: "MyriadProLight", "Lucida Grande", "Lucida Sans Unicode", Arial, sans-serif;
color: #333;
text-transform:uppercase;
line-height: 21pt;
font-weight: normal;
letter-spacing: 0px;
margin: 0px 0px 10px 0px;
padding: 0px;
}
.iconimage
{
margin-right: 7px;
vertical-align: middle;
}
</style>
</head>
<body>
<h1><img class="iconimage" src="image.png" />This is the header</h1>
</body>
</html>
整個頁面代碼在這裏起作用。你能發佈所有的HTML嗎? – KatieK 2010-10-06 17:17:57
@KatieK - 更新了這個問題,但它非常簡單,因爲我一直在測試這個。謝謝! – Martin 2010-10-06 17:56:22