如何调试div/span的高度?
问题描述:
我有HTML这样的:如何调试div/span的高度?
<div>
<span style="display: inline-block;height:20px">20</span>
<span style="display: inline-block;"><img src="img/ex.png"/></span>
</div>
我第二范围导入的图像15×15像素
我可以用铬检查,我可以看到,第一张图片有身高15 和第二个跨度高度为21.(第一个高度为20,如预期)
有人可以告诉我为什么第二个跨度有高度21而不是15?
谢谢,它的驾驶我坚果
我加入下面的颂歌:
<!DOCTYPE html>
<html>
<head>
<style>
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
</style>
</head>
<body>
<div>
<span style="display: inline-block;height:20px">20</span>
<span style="display: inline-block;"><img src="img/ex.png"/></span>
</div>
</body>
</html>
答
那么无论是图像比你想象的大,图像有填充/保证金,你是不是服用或者跨度有你没有考虑到的填充/余量。
- 检查Chrome中的每个元素,然后跨越第一个图像。
- 展开度量在窗口的右侧
- 小图会告诉你每个贡献者元素大小为(填充,边距,边框,元素大小)
+0
我已经添加了代码来显示您。请试用16x16的图像,你会发现包裹图像的跨度更大。 – Zo72
答
测试在我页面,高度为15px
你是否设置了任何跨度填充?
或尝试做*{padding:0;margin:0;}
。
,或者使.span{padding:0!important;margin:0!important;}
或添加
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
页面顶部的W3C
答
使用Chrome的开发者工具来检查元素和微量元素的计算样式。我认为你很可能从某个地方选择了填充样式。
是否有任何样式定义?即。 span {padding:3px; } – AVProgrammer
更多的代码(特别是CSS)/演示网站会有很大的帮助。 –
没有css。 – Zo72