CSS边距顶部适用于每个按钮,而不仅仅是一个[重复]

fiei3ece  于 2023-01-10  发布在  其他
关注(0)|答案(2)|浏览(130)
    • 此问题在此处已有答案**:

Align inline-block DIVs to top of container element(5个答案)
2天前关闭。
我正在看一个yt教程,我似乎找不到这个问题的答案。我只是想在600px和500px的按钮顶部边缘

.subscribe-button {
  background-color: rgb(200, 0, 0);
  color: white;
  border: none;
  height: 30px;
  width: 90px;
  border-radius: 20px;
  cursor: pointer;
  padding: 1px;
  margin-right: 20px;
  margin-top: 600px;
}

.join-button {
  background-color: white;
  border-color: rgb(13, 185, 253);
  border-style: solid;
  border-width: 1px;
  color: rgb(13, 185, 253);
  height: 30px;
  width: 60px;
  cursor: pointer;
  margin-right: 20px;
  margin-top: 500px;
}

.tweet-button {
  background-color: rgb(0, 195, 255);
  color: white;
  border-style: solid;
  border-radius: 20px;
  border: none;
  height: 30px;
  width: 70px;
  cursor: progress;
  font-weight: bold;
}
<button class="subscribe-button">
  Subscribe
</button>
<button class="join-button">
  Join
</button>
<button class="tweet-button">
Tweet
</button>

这是代码this is the image
我尝试了我上面说的话,我期望它能起作用。

jm81lzqq

jm81lzqq1#

您需要将垂直对齐设置为基线默认值以外的值,例如顶部:

.subscribe-button {
  background-color: rgb(200, 0, 0);
  color: white;
  border: none;
  height: 30px;
  width: 90px;
  border-radius: 20px;
  cursor: pointer;
  padding: 1px;
  margin-right: 20px;
  margin-top: 600px;
}

.join-button {
  background-color: white;
  border-color: rgb(13, 185, 253);
  border-style: solid;
  border-width: 1px;
  color: rgb(13, 185, 253);
  height: 30px;
  width: 60px;
  cursor: pointer;
  margin-right: 20px;
  margin-top: 500px;
}

.tweet-button {
  background-color: rgb(0, 195, 255);
  color: white;
  border-style: solid;
  border-radius: 20px;
  border: none;
  height: 30px;
  width: 70px;
  cursor: progress;
  font-weight: bold;
}

button {
  vertical-align: top;
}
<button class="subscribe-button">
  Subscribe
</button>
<button class="join-button">
  Join
</button>
<button class="tweet-button">
Tweet
</button>
kyxcudwk

kyxcudwk2#

添加属性vertical-align:每个按钮的顶部,加上边距-顶部:500 px到最后一个

button
{
   vertical-align: top;
}

.tweet-button
{
    margin-top: 500px; /* It's missing in the code */
}

相关问题