Style fontSizeAdjust 属性
 Style 对象
 Style 对象
定义和用法
fontSizeAdjust 属性设置或返回文本的字体 aspect 值。
所有字体都有 aspect 值,即小写字母 "x" 和大写字母 "X" 之间的尺寸差异。
当第一选择字体不可用时,fontSizeAdjust 属性让您更好地控制字体尺寸。当某种字体不可用时,浏览器使用指定的第二种字体。这可能会导致字体尺寸的改变。为了防止这种情况,请使用该属性。
当浏览器知道第一选择字体的 aspect 值时,浏览器可以计算出使用第二选择字体显示文本时要使用的字体尺寸。
语法
设置 fontSizeAdjust 属性:
Object.style.fontSizeAdjust="none|value|inherit"
返回 fontSizeAdjust 属性:
Object.style.fontSizeAdjust
| 值 | 描述 | 
|---|---|
| none | 默认。不要保留第一选择字体的 x-height。 | 
| value | 保留第一选择字体的 x-height,并计算字体的 aspect 值比率。 使用的公式:首选字体的字体尺寸 * (第一选择字体的 aspect 值 / 可用字体的 aspect 值) = 可用字体的字体尺寸 实例:如果 14px 的 Verdana(aspect 值是 0.58)不可用,但是某个可用的字体(Times New Roman)的 aspect 值是 0.46,那么替代字体的尺寸将是 14*(0.58/0.46) = 17.65px。 | 
| inherit | fontSizeAdjust 属性的值从父元素继承。 | 
浏览器支持





只有 Firefox 支持 fontSizeAdjust 属性。
实例
实例
调整字体尺寸:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>代码学院(codexy.cn)</title>
<script>
function displayResult(){
document.getElementById("p1").style.fontSizeAdjust="0.58";
}
</script>
</head>
<body>
<p id="p1">这是一些文本</p>
<br>
<button type="button" onclick="displayResult()">调整字体大小</button>
 
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>代码学院(codexy.cn)</title>
<script>
function displayResult(){
document.getElementById("p1").style.fontSizeAdjust="0.58";
}
</script>
</head>
<body>
<p id="p1">这是一些文本</p>
<br>
<button type="button" onclick="displayResult()">调整字体大小</button>
</body>
</html>
尝试一下 »
 Style 对象
 Style 对象			
						
			
 JavaScript 教程
JavaScript 教程 JavaScript 对象
JavaScript 对象 jQuery 教程
jQuery 教程 JSON 教程
JSON 教程 AngularJS 教程
AngularJS 教程 Angular 2 教程
Angular 2 教程 Vue.js 教程
Vue.js 教程 React 教程
React 教程 jQuery UI 教程
jQuery UI 教程 jQuery EasyUI 教程
jQuery EasyUI 教程 AJAX 教程
AJAX 教程 Highcharts 教程
Highcharts 教程 Google Maps API 教程
Google Maps API 教程 ES6 教程
ES6 教程 TypeScript教程
TypeScript教程 ES6 标准入门
ES6 标准入门