I don’t want to reinvent the bikes.

  • Can. Set both here and there one value for width, why not. And adjacent left / right? And give an example of markup. - edem
  • @edem You cannot set a single value for width here or there, since I do not know him. The width of an element is determined by its contents. I understand you can not do this on CSS. - user208916
  • Yes, you specify all the details in the question itself, but we'll see. The next element from which we take the width to be left or right of the desired element? - edem
  • one
    CSS does not have access to the applied parameters. Since the width is unknown and the one that is used is needed, only JS is easy there. - user207618
  • @Other Yes, it’s easy to design bikes there: D - user208916

2 answers 2

You can take a similar approach:

 .wrapper { border: 1px solid black; display: table; } .wrapper div { display: table-cell; border: 1px solid blue; width: 50%; word-break: break-all; } 
 <div class="wrapper"> <div contenteditable>Нажмите для редактирования</div> <div>Соседний блок</div> </div> <div class="wrapper"> <div>Ещё блок с каким-то содержимым.</div> <div>Другой соседний блок</div> </div> 

    Use for this selector +

     .class1 + .class2 { width: 100%; } 
    • It is impossible to set both there and there one for width; I do not know him. The width of an element is determined by its contents. So the "+" is not the solution. - user208916