我制作了 HTML 頁面,但在這里我無法在影像下精確對齊文本。請告訴如何洗掉右側的額外空間我已經用谷歌搜索了邊距/填充 0 也嘗試了 display: inline-block 但仍然無法找出解決方案?
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.stack.imgur.com/p5IBx.jpg [我的結果][1] [1]: https://i.stack.imgur.com/DKB5Y .png
uj5u.com熱心網友回復:
您需要從“背景關系”和“粗體”類中洗掉高度和寬度。這是輸出:
body{
text-align: center;
width: 1440px;
background-color: hsl(212, 45%, 89%);
font-family: 'Outfit', sans-serif;
font-size: 15px;
}
.bold{
font-weight: 700;
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{
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>
<!-- <footer>
<div >
Challenge by <a href="https://www.frontendmentor.io?ref=challenge" target="_blank">Frontend Mentor</a>.
Coded by <a href="#">Utsavi Patil</a>.
</div>
</footer> -->
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/493622.html
上一篇:帶有css的影像漸變