CSS网格不起作用。频道图片和文本必须在网格中,但文本在频道图片下面。我在哪里犯了错误?
请帮帮忙。最后两句话是为了给我的该死的帖子添加更多的细节。所以是的接下来的几句话也是无用的。不要再阅读这些句子了,兄弟。该死的,最后那个“添加更多细节”消失了
browser picture
<!DOCTYPE html>
<html>
<head>
<title>YouTube.com</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap"
rel="stylesheet"
/>
<style>
p {
font-family: Roboto, Arial;
margin-top: 0;
margin-bottom: 0;
}
.thumbnail {
width: 300px;
display: block;
}
.thumbnail-row {
margin-bottom: 12px;
}
.search-bar {
display: block;
}
.video-title {
font-size: 16px;
font-weight: 500;
line-height: 20px;
margin-bottom: 12px;
}
.video-preview {
display: inline-block;
width: 300px;
vertical-align: top;
margin-right: 20px;
}
.video-info-grid {
display: grid;
grid-template-columns: 50px, 1fr;
}
.profile-picture {
width: 40px;
border-radius: 25px;
}
.thumbnail-row {
margin-bottom: 12px;
}
.video-author {
font-size: 14px;
font-weight: 400;
color: rgb(96, 96, 96);
margin-bottom: 4px;
}
.video-stats {
font-size: 14px;
font-weight: 400;
color: rgb(96, 96, 96);
}
</style>
</head>
<body>
<input class="search-bar" type="text" placeholder="Search" />
<div class="video-preview">
<div class="thumbnail-row">
<img class="thumbnail" src="images/iAmTheDanger.webp" />
</div>
<div class="video-info-grid">
<div class="channel-picture">
<img class="profile-picture" src="images/danLysaik.jpg" />
</div>
<div class="video-info">
<p class="video-title">
Breaking Bad - Walt: "I am the one who knocks"
</p>
<p class="video-author">Dan Lysiak</p>
<p class="video-stats">10M views · 11 years ago</p>
</div>
</div>
</div>
</body>
</html>
我还以为会有一个合适的网格
1条答案
按热度按时间fzsnzjdm1#
文本在配置文件图片下面,因为您的网格CSS中有一个错误;
grid-template-columns: 50px, 1fr;
不应该有,
。只需删除逗号(使其为
grid-template-columns: 50px 1fr;
),文本将位于图像旁边。