S
S
softshape2018-02-08 07:58:29
css
softshape, 2018-02-08 07:58:29

How to limit div width spreading?

There is a wrapper that contains a table and a signature. It is assumed that the width of the wrapper is determined by the table. Everything is OK until the signature gets too long. She doesn't want to wrap to the second line until the wrapper has a fixed width.
5a7bd85a1c8bc956101149.png
However, it is not possible to set a fixed width for the wrapper, because table width can be changed.
The question is how to make the signature not expand the container, but always fit into it in width and wrap it to another line, if necessary?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Ankhena, 2018-02-08
@softshape

https://jsfiddle.net/Ankhena/m8zgqtzt/

<main>
  <table>
    <tr>
      <td>ss</td>
      <td>ss ss</td>
      <td>ss ssss</td>
      <td>ss</td>
      <td>ss</td>
    </tr>
  </table>
  <div>Текст не больше ширины таблицы.</div>
</main>

main {
  position: relative;
  display: inline-block;
  outline: 1px solid #999;
}

table {
  background: #aaa;
}

div {
  position: absolute;
  background: #eee;
}

D
Dima, 2018-02-08
Dolgoter @DDolgy

If it doesn't work, grab the table width dynamically using js and insert it into the max row width

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question