html - Chrome 检查工具不反射(reflect)浏览器窗口,对齐 Div

标签 html css google-chrome firefox

我一直挠头想知道在使用 html/css 制作基本导航标题时我做错了什么。

Firefox dev tools 显示我的设计是正确的,但是 chrome dev tools/jsfiddle 却另有说法。

enter image description here

Chrome :

enter image description here

注意紫色线条。它们在 chrome 中没有正确对齐,“联系人”不应该被截断

以下 html/css 代码的基本要点:(展开整页)

.nav-background {
    background-color: green;
    width: 100%;
    height: 80px;
    position: fixed;
    top:0;
    padding: 0px;
}

.nav-img {
    display: inline-block;
    width: 60px;
    height: 100%;
}

.nav-img img {
    height: 48px;
    padding-top: 16px;
}

.nav-links {
    float: right;
    padding: 0px;
    display: flex;
    justify-content: flex-end;
    width:900px;
    height: 100%;
}

.nav-links a {
    padding-top: 20px;
    color: white;
    font-size: 2rem;
    margin-left: 1em;
}

.container {
    margin: 0 auto;
    width: 960px;
    height: 100%;
}


.about-me {
    margin: 0 auto;
    width: 960px;
    height: 200px;
    background-color: #aaa;
}
<div class="nav-background">
	<div class="container">
		<div class="nav-img"><img src="http://via.placeholder.com/150x150"></div><!--nav-img-->
		<div class="nav-links">
			<a href="#about">About</a> <a href="#portfolio">Portfolio</a> <a href="#links">Contact</a>
		</div><!--nav-links-->
	</div><!--container-->
</div><!--nav-background-->

<div class="about-me">
</div><!--about-me-->

最佳答案

body 元素上的边距把东西扔掉了。

尝试:

body {
    margin: 0;
}

演示:https://jsfiddle.net/80q8esjf/

关于html - Chrome 检查工具不反射(reflect)浏览器窗口,对齐 Div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47405372/

相关文章:

css - 对帖子的反向悬停效果

html - 如何在悬停一个 div 并排除所有其他 div 时突出显示两个 div?

javascript - CSS 中的侧面板

javascript - 在 chrome javascript 控制台中触发表单提交

html - 禁用文本输入不样式

javascript - 将 JS 变量传递给 HTML 文件

html - 具有固定背景附件的非矩形 block

python - 如何在不破坏标签的情况下截断 html?

google-chrome - 更新 Chrome 后,Chrome 开发者工具栏中的搜索行消失了。如何取回?

html - Google Chrome 表单自动填充及其黄色背景