html - 为什么我的内容和浏览器屏幕端之间存在分离?
问题描述
我网站上的所有内容与浏览器窗口的末尾之间有一个小的差距,我无法弄清楚它为什么会在那里。这就是我的英雄形象的 CSS 代码的样子。
这是该图像的 HTML,以及与我有相同分离问题的图像下方的横幅。
.container {
position: relative;
text-align: center;
color: white;
}
.full-width-banner {
position: auto;
background-color: #466995;
padding: 200px;
top: 20px;
text-align: center;
height: 100px;
text-height: 40px;
width: 73%;
overflow: none;
color: white;
font-family: 'Oswald', sands serif;
font-size: 20px
}
<div class="full-width-banner">
<h2> “Change will not come if we wait for some other person or some other time. We are the ones we’ve been waiting for. We are the change that we seek.” </h2>
<p>Barack Obama<p>
</div>
这是一张图片,在图片和左侧浏览器页面的末尾之间有一个空白。图片应该完全覆盖浏览器的一部分,两边都没有边框。
我不知道为什么会发生这种情况或如何解决它。
解决方案
默认情况下,您的浏览器会为您的主体添加几 px 的边距或/和内边距,只需确保在 CSS 的开头清除它,如下所示:
body {
margin: 0;
padding: 0;
}
img {
display: block;
}
<img class="full-width-banner" src="https://ijnet.org/sites/default/files/styles/full_width_node/public/story/2020-07/cooper-baumgartner-J9QvzfkQM44-unsplash.jpg?h=8c0e36cd&itok=F6g99LH1">
推荐阅读
- r - 在 Base R 中使用 file 和 cat 创建日志文件
- vba - 如何绕过使用 Excel VBA 回复邮件时生成错误的 Outlook 项目?
- java - Firestore 需要双嵌套表
- django - django runserver 不显示启动开发服务器消息
- vuejs2 - How to run a function with a delay from inside axios then
- java - 爪哇。无法从导入 java.security.Signature 导入 SHA256withRSA 签名
- leaflet - 无法让 dashArray 在 Leaflet 1.0.3 中的画布上工作
- redis - 如何获取 Redis 中键集的大小(以字节为单位)?
- java - 无法将 Premium_Fragment 转换为 Activity
- wso2 - WSO2IS-5.3.0 的 OIDC SSO 中缺少声明