html - CSS <a> 标签比里面的图片长吗?

标签 html css

<分区>

我在检查 firefox 和 chrome 上的元素时发现 a 元素比其中的图像长。图片为 102px,a 为 106.4px。我想知道额外的 4.4 像素从何而来?

原始图像为 102 像素 x 102 像素。

Image Size Screenshot

a tag Size Screenshot

这是我的代码(也在 jsfiddle https://jsfiddle.net/g5nsL52a/ 上):

header {
	min-height:102px;
	text-align:center;
	font-family: "Felix Titling Regular", Times, serif;
}
header a {
	display:inline-block;
	position:absolute;
	left:0;
}

header h1 {
	display:inline-block;
	position:relative;
	top:29px;
	font-size:300%;
	text-transform:capitalize;
}
<header>
  <a href="index.html">
    <img src="https://images.pexels.com/photos/430205/pexels-photo-430205.jpeg" width="102" height="102" alt="Godfather Logo" title="Godfather Small Logo"/>
  </a>
  <h1> loyal capos to the don </h1>
</header>

最佳答案

header a{
    display:inline-block;
    position:absolute;
    left:0;
    height:102px;
    width:102px;
    padding:0;
    margin:0;
}

关于html - CSS <a> 标签比里面的图片长吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47952120/

上一篇:html - NavBar 边距 : auto, 不起作用

下一篇:html - 背景图片不会在手机上显示 (iPhone 6s)

相关文章:

javascript - 有没有办法使用任何浏览器的开发工具来扩展整个 dom 树?

html - Visual Studio 2017 html 标签选择器

html - CSS - Rails 4 - Bootstrap -

html - 包装器 div 的正确高度的绝对/相对位置?

html - 固定标题表在调整窗口大小时变形

javascript - 使用 JavaScript 触发 CSS 动画淡入淡出 - 仅在一个方向上有效?

javascript - 如何更改选择多个下拉菜单的默认背景

html - Django 表单中复选框的文本

html - 边界元。元素可以包含 block 吗?

javascript - 制作垂直 UL slider