gpt4 book ai didi

html - 如何删除 div 之间的垂直空白

转载 作者:太空宇宙 更新时间:2023-11-04 01:31:05 24 4
gpt4 key购买 nike

我的边框 div 之间出现了一些空白,我不想要它。这里的大多数解决方案都与具有宽度和高度等其他方面的 div 相关联,但我的是纯文本。

.h1z1 {
text-align: center;
}
.g1 h2, .g2 h2, .g3 h2 {
padding: 10px;
background-color: #ccffcc;
}
.g1, .g2, .g3 {
border-left: 6px solid #00ff00;
}
<body style="font-family: 'Source Code Pro', monospace;">
<div class="header"></div>
<div class="gtitle">
<h1 class="h1z1">Graphics Cards</h1>
<hr />
</div>
<div class="g1">
<h2>Titan XP</h2>
</div>
<div class="g2">
<h2>Titan X (Pascal)</h2>
</div>
<div class="g3">
<h2>GeForce GTX 1080ti</h2>
</div>
</body>

最佳答案

margin:0; 赋给 .g1 h2, .g2 h2, .g3 h2。因为 h2 有默认边距。

.h1z1{
text-align: center;
}

.g1 h2, .g2 h2, .g3 h2{
padding: 10px;
background-color: #ccffcc;
margin:0;
}

.g1, .g2, .g3{
border-left: 6px solid #00ff00;
}
<body style="font-family: 'Source Code Pro', monospace;">
<div class="header"></div>
<div class="gtitle">
<h1 class="h1z1">Graphics Cards</h1>
<hr />
</div>
<div class="g1">
<h2>Titan XP</h2>
</div>
<div class="g2">
<h2>Titan X (Pascal)</h2>
</div>
<div class="g3">
<h2>GeForce GTX 1080ti</h2>
</div>
</body>

关于html - 如何删除 div 之间的垂直空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47107412/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com