卡住。我如何居中并置于这三个文本?

发布于 2025-02-10 02:25:25 字数 44 浏览 4 评论 0原文

试图离开,中间,右侧3片?试图使用CSS,我卡住了。

谢谢。

Trying to left, center, right the 3 pieces of text? Trying to use CSS and I'm stuck.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

茶色山野 2025-02-17 02:25:25

您可以使用Flex并将其设置为合理的空间之间

#text-container {
  display: flex;
  justify-content: space-between; 

}
<div id="text-container">
  <p>Left</p>
  <p>Middle</p>
  <p>Right</p>
</div>

you could use flex and set justify-content to space-between

#text-container {
  display: flex;
  justify-content: space-between; 

}
<div id="text-container">
  <p>Left</p>
  <p>Middle</p>
  <p>Right</p>
</div>

转身以后 2025-02-17 02:25:25

您可以使用Flex属性来解决此问题。您将拥有一个父母Div,其中包含所有三个孩子的物品。根据您的HTML代码中项目的位置,内容将证明其相应的方面是合理的。因此,如果它是第一个,则将是合理的。如果是第二个,它将是合理的。如果是第三个,它将是合理的。这是您将如何做的;

#bar {
  display: flex;
}

#bar>* {
  flex: 1;
  display: flex;
}

#bar> :nth-child(1) {
  justify-content: flex-start;
}

#bar> :nth-child(2) {
  justify-content: center;
}

#bar> :nth-child(3) {
  justify-content: flex-end;
}
<div id="bar">
  <p>Left</p>
  <p>Middle</p>
  <p>Right</p>
</div>

You could use the flex property to solve this. You would have a parent div which contains all 3 of your children items. Depending on where the item is in your HTML code, the content will justify to its respective side. So if it's the first, it will be justified to the left. If it's the second, it will be justified to the middle. And if it's the third, it will be justified to the right. Here is how you would do it;

#bar {
  display: flex;
}

#bar>* {
  flex: 1;
  display: flex;
}

#bar> :nth-child(1) {
  justify-content: flex-start;
}

#bar> :nth-child(2) {
  justify-content: center;
}

#bar> :nth-child(3) {
  justify-content: flex-end;
}
<div id="bar">
  <p>Left</p>
  <p>Middle</p>
  <p>Right</p>
</div>

爱给你人给你 2025-02-17 02:25:25

我同意其他回应。在

。想要将父div设置为display:flex并根据您想做的事情,您可以设置
Jusify-content:flex-start左,
合理性:flex-end正确,并且
合理性:中心到中心。

I agree with the other responses. Check out this really helpful/visual website on flexboxes

You want to set the parent div as display: flex and depending on what you want to do, you can set
justify-content: flex-start for left,
justify-content: flex-end to right, and
justify-content: center to center.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文