如何修复按钮和文本输入的错位

How to fix misalignment of button and text input

我正在尝试在网站上制作一个带有文本输入、按钮和一些文本的小部分。但是,输入和按钮似乎没有与文本正确对齐。为什么会这样,我该如何解决?

这是我的:

:root {

    --font: "Bebas Neue", cursive;

    --color1: 227, 227, 227; /* Light Grey */
    --color2: 18, 18, 18;    /* Dark Grey  */

}

html, body {

    font-family: var(--font);
    color: rgb(var(--color1));
    background: rgb(var(--color2));
    overflow: hidden;
    flex-direction: column;

}

@keyframes _slide_down {

    0% { top: -200%; }
    10% { top: -100%; }
    100% { top: 0.8%; }

}

.slide_down {

    position: absolute;
    left: 0;
    right: 0;
    top: 0.8%;
    margin-left: auto;
    margin-right: auto;
    animation: _slide_down 5s;

}

.top_left { position: absolute; top: 0.8%; left: 1%; }

.padded { padding: 1%; }

.squircle  { border-radius: 30px; }

.centered { text-align: center; margin: auto; display: block; }

.large { font-family: var(--font); font-size: 300%; }

.medium { font-family: var(--font); font-size: 38%; }

.glowing { text-shadow: 0 0 10px rgba(var(--color1), 0.6); }

._glowing { box-shadow: 0 0 10px rgba(var(--color1), 0.6); }

.right_rounded { border-top-right-radius: 15px; border-bottom-right-radius: 15px; }

.left_rounded { border-top-left-radius: 15px; border-bottom-left-radius: 15px; }

.stretched { width: 45%; }

.squished { width: 13%; }
<link rel = "preconnect" 
            href = "https://fonts.gstatic.com">
    <link href = "https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" 
            rel = "stylesheet">

<div id = "generated_fen"
            class = "large stretched slide_down centered padded glowing">

        FEN Key:

        <input type = "text"
                id = "fenID"
                class = "stretched padded medium left_rounded"
                placeholder = "xxxxxxxx/xxxxxxxx/x/x/x/x/xxxxxxxx/xxxxxxxx x xxxx - x x"/>

        <button type = "button"
                id = "set_to_fen"
                class = "squished padded medium right_rounded"> Set FEN ‎‎‎‎</button>

    </div>

我该如何解决这个问题?我希望我的输入和按钮不完全对齐 div 的顶部,但也不低于文本。如果有意义的话,它们应该与文本完全一致。

这是一个示例,其中橙色线是我希望每个元素的垂直中间对齐的位置。截至目前,您可以看到它们不是。

也许使用 display: flex 而不是块可以帮助解决对齐问题?显式设置按钮和输入的宽度也可能会导致一些问题,因此我删除了这些示例。

:root {
  --font: "Bebas Neue", cursive;
  --color1: 227, 227, 227;
  /* Light Grey */
  --color2: 18, 18, 18;
  /* Dark Grey  */
}

html,
body {
  font-family: var(--font);
  color: rgb(var(--color1));
  background: rgb(var(--color2));
  overflow: hidden;
  flex-direction: column;
}

@keyframes _slide_down {
  0% {
    top: -200%;
  }
  10% {
    top: -100%;
  }
  100% {
    top: 0.8%;
  }
}

.slide_down {
  position: absolute;
  left: 0;
  right: 0;
  top: 0.8%;
  margin-left: auto;
  margin-right: auto;
  animation: _slide_down 5s;
}

.top_left {
  position: absolute;
  top: 0.8%;
  left: 1%;
}

.padded {
  margin: 2px;
}

.squircle {
  border-radius: 30px;
}

.centered {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100px;
}

.large {
  font-family: var(--font);
  font-size: 300%;
}

.medium {
  font-family: var(--font);
  font-size: 38%;
}

.glowing {
  text-shadow: 0 0 10px rgba(var(--color1), 0.6);
}

._glowing {
  box-shadow: 0 0 10px rgba(var(--color1), 0.6);
}

.right_rounded {
  border-top-right-radius: 15px;
  border-bottom-right-radius: 15px;
}

.left_rounded {
  border-top-left-radius: 15px;
  border-bottom-left-radius: 15px;
}
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">

<div id="generated_fen" class="flex large stretched slide_down centered padded glowing">

  <span>FEN Key:</span>

  <input type="text" id="fenID" class="padded medium left_rounded" placeholder="xxxxxxx" />

  <button type="button" id="set_to_fen" class="padded medium right_rounded">Set FEN ‎‎‎‎</button>

</div>