【发布时间】:2022-01-10 19:01:49
【问题描述】:
我一直在尝试将图像添加到没有填充的 div 中,但它的大小似乎有问题。它应该显示的是通常附在下面但底部没有额外空间的内容,但它确实显示的内容(即使在我尝试过的 CSS 乱七八糟之后)显示 the dreadful extra space at the bottom.
我试过min-height、max-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>
请让我知道任何可能的解决方案。
【问题讨论】:
-
img标签最后少了一个/。
-
这能回答你的问题吗? Space at bottom of div containing image
-
在
>之前添加/不会改变输出。