简体   繁体   English

如何将组件放在一行/块中?

[英]How to put components in one line / block?

I need to situate alerts one one line with buttons.我需要将警报与按钮排成一行。 They appear in different situations (states), but even this they doesn't appear more than 1 in the same time.它们出现在不同的情况(状态)中,但即便如此,它们同时出现的次数也不会超过 1 个。 Just need to show them in one line with 'Send button'.只需使用“发送按钮”将它们显示在一行中。 doesn't help.没有帮助。

Thanks for any help.谢谢你的帮助。

This is my code:这是我的代码:

      <Form.Group className="m-0">
        <Form.Control>
// starting here
        <Button>
          {isLoading ? 'Sending...' : 'Send feedback'}
        </Button>
        {isLoading && showTimer && (
          <CancelButton         )}
        {tooShortFeedback && !isLoading && (
          <WarningAlert message="Your feedback must be more than 10 symbols" />
        )}
        {attemptCount && (
          <DangerAlert message={tooLong} />
        )}
        {tooLongFeedback && !attemptCount && (
          <WarningAlert message={tooLong} />
        )}
        {feedbackNotSent && !isLoading && (
          <DangerAlert message="Your feedback was not sent. Try again" />
        )}
// finishing here
      </Form.Group>

This is schema how it looks now:这是现在的模式:

Button按钮

Alert警报

And this is what I need: Button Alert这就是我需要的:按钮警报

As mentioned by @CaptainMhmdrz_A in the comments.正如@CaptainMhmdrz_A 在评论中提到的那样。 You need to update the CSS of these buttons.您需要更新这些按钮的 CSS。 From display:block to display:inline-block or display:inlinedisplay:blockdisplay:inline-blockdisplay:inline

To get everything in one line you could use display:flex要将所有内容放在一行中,您可以使用display:flex

https://www.w3schools.com/css/css3_flexbox.asp https://www.w3schools.com/css/css3_flexbox.asp

    <div style={{display:'flex'}}>
        <Button>
          {isLoading ? 'Sending...' : 'Send feedback'}
        </Button>
        {isLoading && showTimer && (
          <CancelButton         )}
        {tooShortFeedback && !isLoading && (
          <WarningAlert message="Your feedback must be more than 10 symbols" />
        )}
        {attemptCount && (
          <DangerAlert message={tooLong} />
        )}
        {tooLongFeedback && !attemptCount && (
          <WarningAlert message={tooLong} />
        )}
        {feedbackNotSent && !isLoading && (
          <DangerAlert message="Your feedback was not sent. Try again" />
        )}
    </div>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM