[英]Google Chrome Developer tools shows browser default font size as 18 pixels?
The default font size is known to be 16 pixels. 默认字体大小已知为16像素。 I made a simple page and tested this out.
我做了一个简单的页面并进行了测试。 I looked at the Developer Tools in Google Chrome and it says 18 (yes I removed margin and padding to the paragraph element).
我查看了Google Chrome浏览器中的开发人员工具,显示为18(是的,我删除了margin和padding到段落元素)。 I ran the following JavaScript to manually get the font size to see if it was 16px and it was.
我运行以下JavaScript来手动获取字体大小,以查看它是否为16px。 What is this number 18 from?
这个数字18是什么来的?
var el = document.getElementById('hello'); var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); var fontSize = parseFloat(style); console.log(fontSize);
<p id='hello'>Hello world</p>
The line-height
. line-height
。 Set line-height: 1;
设置
line-height: 1;
and the height will be 16px. 高度为16像素。
var el = document.getElementById('hello'); el.style.lineHeight = '1'; var style = window.getComputedStyle(el, null).getPropertyValue('font-size'); var fontSize = parseFloat(style); console.log(fontSize);
<p id='hello'>Hello world</p>
The area selected by the Chrome Dev Tools includes the line-height
(see https://developer.mozilla.org/en/docs/Web/CSS/line-height ), and any padding
/ margin
around the p
element. Chrome开发者工具选择的区域包括
line-height
(请参阅https://developer.mozilla.org/en/docs/Web/CSS/line-height )以及p
元素周围的任何padding
/ margin
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.