如何在图像下精确设置文本并删除额外的空间?
我已经制作了HTML页面,但是在这里,我无法在图像下完全对齐文本。 请告诉我如何删除右侧的额外空间,我搜索过用保证金/填充0的Google Google还尝试了显示:内联块,但仍然无法找出解决方案是什么?
body {
text-align: center;
width: 1440px;
background-color: hsl(212, 45%, 89%);
font-family: 'Outfit', sans-serif;
font-size: 15px;
}
.bold {
font-weight: 700;
width: 45%;
height: 45%;
color: hsl(218, 44%, 22%);
}
img {
width: 50%;
height: 50%;
border-radius: 5%;
}
.container {
display: inline-block;
background-color: hsl(0, 0%, 100%);
padding: 17px;
border-radius: 5%;
}
.context {
width: 45%;
height: 45%;
color: hsl(220, 15%, 55%);
/* display: flex; */
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<title>Frontend Mentor | QR code component</title>
<!-- CSS Style Sheet -->
<link rel="stylesheet" href="styles.css">
<!-- Google Fonts -->
<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=Outfit:wght@400@700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<img src="images\image-qr-code.png" alt="QRCode Loading">
<p class="bold">Improve your front-end skills by building projects</p>
<p class="context">Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
</div>
</body>
</html>
[想要结果] [1] [1]:https://i.sstatic.net/p5ibx.jpg [我的结果] [1] [1]:https://i.sstatic.net/dkb5y.png
I have made HTML Page but here I am not able to Align text exactly under image.
please tell how to remove extra space on right side I have googled tried with margin/padding 0 also tried display: inline-block but still not able to find out what is the solution?
body {
text-align: center;
width: 1440px;
background-color: hsl(212, 45%, 89%);
font-family: 'Outfit', sans-serif;
font-size: 15px;
}
.bold {
font-weight: 700;
width: 45%;
height: 45%;
color: hsl(218, 44%, 22%);
}
img {
width: 50%;
height: 50%;
border-radius: 5%;
}
.container {
display: inline-block;
background-color: hsl(0, 0%, 100%);
padding: 17px;
border-radius: 5%;
}
.context {
width: 45%;
height: 45%;
color: hsl(220, 15%, 55%);
/* display: flex; */
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- displays site properly based on user's device -->
<link rel="icon" type="image/png" sizes="32x32" href="./images/favicon-32x32.png">
<title>Frontend Mentor | QR code component</title>
<!-- CSS Style Sheet -->
<link rel="stylesheet" href="styles.css">
<!-- Google Fonts -->
<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=Outfit:wght@400@700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<img src="images\image-qr-code.png" alt="QRCode Loading">
<p class="bold">Improve your front-end skills by building projects</p>
<p class="context">Scan the QR code to visit Frontend Mentor and take your coding skills to the next level</p>
</div>
</body>
</html>
[wanted result][1] [1]: https://i.sstatic.net/p5IBx.jpg
[My result][1] [1]: https://i.sstatic.net/DKB5Y.png
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从“上下文”和“粗体”类中删除高度和宽度。这是输出:
You need to remove height and width from "context" and "bold" class. Here is the output: