Align first div to left with subsequent divs aligned right

前端 未结 3 962
[愿得一人]
[愿得一人] 2021-01-24 18:21

I wish to display three pieces of text on the same horizontal line, as follows:

|                                                            |
| Chapter one              


        
3条回答
  •  感情败类
    2021-01-24 18:46

    #container {
      display: flex;
    }
    #container > div:first-child {
      margin-right: auto;
    }
    Chapter one
    Language: 
    English

    Whether you ultimately have one or two divs on the right (depending on your combo box set-up), the method above will work. It basically keeps the first div flush left and everything else flush right.

    More details here:

    • Aligning Three Divs Horizontally Using Flexbox
    • Methods for Aligning Flex Items

    Browser support: Flexbox is supported by all major browsers, except IE < 10. Some recent browser versions, such as Safari 8 and IE10, require vendor prefixes. For a quick way to add prefixes use Autoprefixer. More details in this answer.

提交回复
热议问题