字体大小大于CSS中的设置
当我将字体大小设置为特定的像素高度时,计算出的字体大小是我在CSS中设置的大小的1.333倍。但是,如果将字体大小设置为百分比,则会使用正确的大小。这在我尝试过的所有浏览器中都会发生,包括Firefox 3.6.28、Firefox 53.0.3(32位和64位)、Internet Explorer、Safari、Chrome和Opera 下面是一个简化的问题示例:字体大小大于CSS中的设置,css,fonts,Css,Fonts,当我将字体大小设置为特定的像素高度时,计算出的字体大小是我在CSS中设置的大小的1.333倍。但是,如果将字体大小设置为百分比,则会使用正确的大小。这在我尝试过的所有浏览器中都会发生,包括Firefox 3.6.28、Firefox 53.0.3(32位和64位)、Internet Explorer、Safari、Chrome和Opera 下面是一个简化的问题示例: <?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>TocMenu Test</title>
<link href="/style/styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
body
{ background:#000000 url('/graphics/l5-back-eso1213a-2K.jpg') repeat fixed;
color:#ffffe8;
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:14px;
font-weight:normal;
}
img
{ border:0;
margin:0;
padding:0;
}
#menuRoot *
{ min-width:0;/* peek-a-boo bug fix for IE7 */
position:relative;/* peek-a-boo bug fix for IE6 */
}
#menuRoot img
{ padding:3px;
}
.tocRoot
{ padding:0;
}
.tocLevel1
{ font-size:16.8pt; /* 120% */
font-weight:bold;
margin-top:9px;
}
.tocLevel2
{ font-size:15.4pt; /* 110% */
font-weight:bold;
margin-top:6px;
}
.tocMenuOpen
{ background:none;
color:#ffff66;
list-style:none;
}
.tocMenu1
{ padding-left:30px;
}
.tocLink, a.tocLink
{ color:#99ff99;
text-decoration:none;
}
.tocBtn, .tocBtnNot
{ display:inline-block;
text-align:left;
vertical-align:text-top;
width:14px;
}
</style>
</head>
<body>
<ul id="menuRoot" class="tocMenuOpen tocRoot">
<li>
<p class="glueDown">
<span class="tocBtn" id="menuHome_bn"><img src="/graphics/imgOpen.gif" alt="menu state indicator" /></span>
<a href="//L5Development.com" class="tocLevel1 tocLink" title="The L5 Development Group - A For-Profit Private Enterprise Space Exploration and Development Program">Home</a>
</p>
<ul id="menuHome" class="tocMenuOpen tocMenu1">
<li>
<p class="glueDown">
<span class="tocBtnNot"> </span>
<a href="/TodaysNews.php" class="tocLevel2 tocLink" title="News about The L5 Development Group, space travel, space business, and related issues">Today's News</a>
</p>
</li>
</ul>
</li>
</ul>
</body></html>
如果我将tocLevel1和tocLevel2字体大小值从像素高度更改为CSS注释中显示的百分比值,则页面工作正常
当字体大小值设置为特定高度时,为什么每个浏览器都决定使用比CSS中设置的字体大小大三分之一的字体大小?您的字体大小混合了像素像素和像素点。14px的120%将是16.8px,但您已将单位指定为点,这两个点不同,而且更大
我建议只使用一个单位,这样比较容易调整。或者使用绝对尺寸作为基本尺寸,其他尺寸使用相对尺寸。注意:Pah!是的,你是对的,这个问题发生在我睡觉的时候,当我回到我的办公桌上时确认了…点对像素-这是我半睡时编码得到的