html - 背景图像未从顶部 CSS 中出现
问题描述
There is a gap above the top of the image. What is causing it? I want the image to appear from the very top of the page. The image covers takes up half the width of the webpage.
HTML(这里我添加了一个导航栏,并且有一个包含图像的 div 标签。)
<nav class="navbar">
<ul>
<li><a href ="#home"><div class ="line-effect">Home</div></a></li>
<li><a href ="#about"><div class="line-effect">About</div></a></li>
<li><a href ="#portfolio"><div class="line-effect">Portfolio</div></a></li>
</ul>
</nav>
<div class="bg-image">
<img src="newvec.png" height="800px" width="750px">
</div>
CSS(这是导航栏的样式。没有应用于图像的样式。“box:sizing:border-box”属性已应用于整个文档。)
.navbar{
padding:5px;
display: flex;
justify-content: flex-end;
align-items: center;
position:fixed;
padding:50px 10px;
width:100%;
height:8vh;
}
.navbar ul{
display: flex;
list-style: none;
padding: 20px 40px;
}
.navbar ul li a{
font-family: Nunito;
color:black;
text-decoration: none;
font-size: 20px;
display: block;
padding: 5px 25px;
}
解决方案
你检查过你的<body>
标签吗?如果您没有使用标签
中reset.css
的标准。
只是尝试添加margin
<body>
body {
margin : 0;
}
在你的 CSS 标签上。
推荐阅读
- python - 无法使用 LXML 通过标签在 XML 中查找元素
- javascript - 为什么这个使用散列搜索字符串的函数不起作用?
- laravel - 如何使用 Vue Js 自定义全日历?
- machine-learning - Dlib 的 MLP 实现有什么限制吗?
- c# - API Json 反序列化 C# 类
- ios - 在 iOS 13 中设置 UISearchField 的占位符文本颜色
- bootstrap-datetimepicker - Bootstrap 日期选择器 仅以字符格式显示月份和年份
- regex - 如何使用反应和正则表达式将字符串中的模式替换为其他字符串?
- android - EMUI 中的 Spinner 下拉视觉错误(华为、荣耀)
- javascript - Webpack 开发服务器和 WebSockets