.container>span.a+span.b+span.c 

How on css to make so that span.b was on the center .container which is stretched on all width, and span.a and span.c nestled on the edges?
What can not just center them, because span.b sizes can vary, but it should always be centered.

    3 answers 3

    Put them inside centered and use absolute.

     body { text-align: center; } .c { display: inline-block; height: 4em; background: silver; text-align: left; position: relative; } .l { position: absolute; right: 100%; border: 1px solid; } .r { position: absolute; left: 100%; border: 1px solid; } 
     <div class=c> <div class=l>12345678901234567890</div> <div class=r>123</div> Some centered content </div> 

    • you can show an example, but it seems that you didn’t have enough strength for the last sentence .. - vas
    • one
      @vas, I added, but in general, immediately putting a minus is somehow not very good. Might first wait for the response to the comment. - Qwertiy

    I think you meant the following behavior.

     .container { border: 1px solid black; width: 200px; text-align: center; display: flex; justify-content: center; } .a, .c { width: 0; position: relative; } .a:before { content: "a"; color: red; position: absolute; right: 0; } .c:after { content: "ccccccccc"; color: green; position: absolute; } .b { color: blue; } 
     <div class="container"> <span class="a"></span> <span class="b">bbbb</span> <span class="c"></span> </div> 

      Try this:

       div.container { background: red; overflow: hidden; text-align: center; } span { border: 1px solid white; } 
       <div class="container"> <span class="a"> Lorem ipsum. </span> <span class="b"> Lorem ipsum dolor sit amet.Lorem ipsum. </span> <span class="c"> Lorem ipsum. </span> </div> 

      • and in your example, swap the content of the first to the second and see what happens. - vas
      • @vas What do you want? Do you think your left span will be great, but at the same time that it does not affect the central one? Then make separate blocks, that's all, and I can bet minus. - user192664
      • for a start, I want the respondents to be not so exhausted that they have enough strength to finish reading the two sentences. Apparently you are responsible for the title. - vas
      • show how to do with different blocks? - vas