【问题标题】:How can I remove the extra space at the bottom of a div? [duplicate]如何删除 div 底部的多余空间? [复制]
【发布时间】:2022-01-10 19:01:49
【问题描述】:

我一直在尝试将图像添加到没有填充的 div 中,但它的大小似乎有问题。它应该显示的是通常附在下面但底部没有额外空间的内容,但它确实显示的内容(即使在我尝试过的 CSS 乱七八糟之后)显示 the dreadful extra space at the bottom.

我试过min-heightmax-height、手动设置高度(以像素为单位)和overflow: hidden;

这是我的 CSS 和 HTML:

div.container {
    padding: 3px;
    border: 1px solid black;
}

div.container2 {
    border: 1px solid black;
}

div.container2 .header {
    overflow: hidden;
    height: auto;
}

div.cascade {
    margin: auto;
    width: max-content;
}

div.blackbar {
    background-color: black;
    padding-left: 3px;
    padding-right: 3px;
    color: white;
}

.blackbar a {
    color: white;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="css/gbook.css">
    <title>GBook</title>
</head>
<body>
    <div class="cascade">
        <div class="blackbar"><a href="http://">Log In</a> | <a href="http://">Sign Up</a></div>
        <div class="container2"><img src="assets/gbheader.png" alt="GBook" width="440px" height="68px"></div><br>
        <div class="container">qqq</div>
    </div>
</body>
</html>

请让我知道任何可能的解决方案。

【问题讨论】:

标签: html css


【解决方案1】:

感谢 Laif,我能够简单地将 img 的显示设置为阻止并解决了问题。非常感谢。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    • 1970-01-01
    • 2019-01-24
    相关资源
    最近更新 更多