html - 为什么即使我没有设置任何保证金,我也会得到默认保证金?
问题描述
我已将类设置mainBackground
为 div。尽管我只设置了背景颜色,但我从 chrome 窗口的各个方面都得到了一个边距。我的代码如下:
.mainBackground {
background-color: #ece8e8;
width: 100%;
}
<div class="mainBackground">
hello
</div>
我想删除该 div 标签的边距。
解决方案
* {
margin: 0;
padding: 0;
}
.mainBackground {
background-color: #ece8e8;
width: 100%;
padding: 100px 0;
text-align: center;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="mainBackground">
hello
</div>
</body>
</html>
给保证金:0;和 padding: 0 每个元素!希望它会有所帮助
推荐阅读
- python - 尝试在 python 中将 Object 转换为 Float 时出错
- php - 根据输入变量构造 PHP 方法
- python - 如何使用 Scapy 生成序列号为“first:last”的数据包?
- javascript - 从 Google 表格导入数据不起作用
- python - 使用 beautifulsoup 提取 url 和 title
- pyomo - Pyomo 和 Gurobi:Pyomo 是否支持 Gurobi 的求解器回调?
- sql - Determine the Height and the Width of a BLOB
- swiftui - SwiftUI:将 ClearButton 添加到 TextField
- javascript - ES6 Class 使构造函数“+”能够被使用
- c++ - 模板实例化期间的 gcc 编译错误