【发布时间】:2021-04-01 20:48:47
【问题描述】:
我希望文本就在图像下方,没有空格。我也尝试了 0 边距和 0 填充但没有用。我应该为跨度创建另一个 div 吗?我也尝试了溢出隐藏:(
body 标签中也没有填充,(*)我想知道它是由 display:block 还是 display flex 引起的..
* {
outline: 0px;
box-sizing: border-box;
position: relative;
padding: 0;
margin: 0;
}
body {
background-color: #1b191b;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
background-color: #232223;
width: 100%;
height: 65px;
z-index: 9999;
box-shadow: 0 0 20px #00000094;
}
.header-links ul li a {
text-decoration: none;
}
.header-links ul li {
display: inline;
margin-right: 50px;
}
.header-logo {
padding: 20px;
margin-left: 50px;
}
.search-bar {
padding: 20px;
margin-right: 50px;
}
.container {
width: 93%;
max-width: 1600px;
margin: 0 auto;
}
div.item {
vertical-align: top;
display: inline-block;
text-align: center;
width: 270px;
margin: 0 12px 30px;
}
img {
padding: 0;
width: 100%;
height: 100%;
border-top-left-radius: 3%;
border-top-right-radius: 3%;
}
.caption {
padding: 0;
display: block;
background-color: #232223;
border-bottom-left-radius: 10%;
border-bottom-right-radius: 10%;
}
<!DOCTYPE html>
<html dir="rtl" lang="ar">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Header</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<div class="header-logo">ON ANIME</div>
<div class="header-links">
<ul>
<li><a href="#">url</a></li>
<li><a href="#">url</a></li>
<li><a href="#">url</a></li>
</ul>
</div>
<div class="search-bar"><button>Buy now</button></div>
</header>
<div class="container">
<div class="item">
<img src="https://fr.techtribune.net/wp-content/uploads/2021/01/boruto-chapter-55.jpg"/>
<span class="caption">Text below the image</span>
</div>
</div>
<script src="" async defer></script>
</body>
</html>
【问题讨论】:
-
这能回答你的问题吗? Why have my images got extra spacing?
-
@tacoshy 我只需要添加 display: block;到字幕班..谢谢你
-
或图片如ym sn-p所示。