为什么文本边框不起作用 html css

问题描述 投票:0回答:1

我对 html 和 css 非常陌生,尝试通过创建我的第一个 Web 项目(即待办事项列表)来学习。我有一份我想要的草稿,因为我还不知道如何处理我网站上的日期,所以我只是想制作一个显示随机日期的段落。我希望它看起来像这样:

Desired look

我让它看起来像这样。

问题是,当我改变页面的大小,哪怕是一点时,我都会得到这个:

Actual look

* {
    font-family: "Instrument Serif", serif;
    font-weight: 400;
}

h1 {
    font-size: 50px;
    margin: 10rem 0 1rem 0;
    text-align: center;
    font-weight: 550;
}

.date {
    text-align: center;
    border: 0.5px solid #888579;
    background-color: #ececec;
    color: #888579;
    margin: 0 900px 20px 900px;
    border-radius: 7px;
    padding: 3px;
}

.top-container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.add-input {
    box-shadow: 0 8px 6px -6px #3a3937;
    font-style: italic;
    font-size: 18px;
    padding: 9px 100px;
    border-radius: 7px;
    border: 0;
    text-align: center;
    margin-right: 20px;
    margin-left: 20px;
}

button {
    box-shadow: 0 8px 6px -6px #3a3937;
    font-weight: bolder;
    border: none;
    padding: 9.5px 17px 9px 17px;
    margin: 0 20px 0 10px;
    background-color: #888579;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
}

.box {
    border: 0.2px solid #888579;
    border-radius: 20px;
    padding: 2rem 2rem 2rem 2rem;
    margin: 10px auto 20px;
    width: fit-content;
    height: fit-content;
    background-color: #ebeae8;
}

ul li {
    list-style: none;
    user-select: none;
    font-size: 25px;
    cursor: pointer;
    padding: 10px;
}

footer {
    text-align: center;
    font-weight: 550;
    color: #000000;
    font-size: 12px;
}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>to-do list</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=Instrument+Serif:ital@0;1&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="style.css" />
  </head>

  <body>
    <h1>to-do list</h1>
    <p class="date">05/10/24</p>
    <div class="box">
        <div class="top-container">
            <input type="text" class="add-input" placeholder="my new task is..."></input><br />
            <button>+</button>
        </div>
        <ul class="list-container">
            <li>task 1</li>
            <li>task 2</li>
            <li>task 3</li>
        </ul>
    </div>
    

    <footer>@1wakos</footer>

  </body>
</html>

有人可以帮忙吗?我看不出任何错误

html css
1个回答
0
投票

对于边距,尝试使用 %s 而不是 px 中的硬值,这可能会达到您想要的效果。还可以使用vh(vh代表视点高度,等于视口高度的1%。相对于视口高度)

您还可以尝试 rem 单位(与字体大小相关,在这里可能更有用)

尝试这样的事情: 保证金:50% 50%

© www.soinside.com 2019 - 2024. All rights reserved.