Скролл у position:fixed div

273
21 октября 2017, 17:25

Пытаюсь сделать следующее: два блока с таблицами, которые располагаются слева и справа, соответственно. При этом правая таблица (на рисунке ниже отмечена синим) плавающая - при сролле основной левой таблицы правая следует за ней, оставаясь всегда на виду. Однако если в правой таблице много строк (такое случается редко, но случается), то добраться до последних нет возможности - они прячутся, т.к. блок position:fixed;

Как тут быть? Чтобы правый блок оставался на виду при скролле левой таблицы, но при этом оставался на виду, а если там слишком много записей, то появлялся бы скролл и у этого блока? Есть возможность использовать bootstrap.

#date_range { 
  width: 50%; 
  margin-bottom: 5px; 
} 
 
div#samples_data_div { 
  overflow-y: auto; 
} 
 
div#samples_data_div, 
div#orders_data_div { 
  width: 50%; 
  float: left; 
} 
 
div#orders_data_div { 
  width: 49%; 
  float: right; 
  position: fixed; 
  left: 51%; 
} 
 
#order_data { 
  position: fixed; 
}
<div id="container"> 
  <div id="date_range" class="row text-center">Управление</div> 
  <div id="samples_data_div"> 
    <table border='1'> 
      <thead> 
        <tr> 
          <th>1</th> 
          <th>2</th> 
          <th>3</th> 
          <th>4</th> 
        </tr> 
      </thead> 
      <tbody> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
      </tbody> 
    </table> 
  </div> 
  <div id="orders_data_div"> 
    <div id="order_data"> 
      <table border='1'> 
        <thead> 
          <tr> 
            <th>1</th> 
            <th>2</th> 
            <th>3</th> 
            <th>4</th> 
          </tr> 
        </thead> 
        <tbody> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
        </tbody> 
      </table> 
      <div> 
      </div> 
    </div>

Answer 1

Как вариант растянуть на весь экран и добавить overflow auto.

#date_range { 
  width: 50%; 
  margin-bottom: 5px; 
} 
 
div#samples_data_div { 
  overflow-y: auto; 
} 
 
div#samples_data_div, 
div#orders_data_div { 
  width: 50%; 
  float: left; 
} 
 
div#orders_data_div { 
  width: 49%; 
  float: right; 
  position: fixed; 
  left: 51%; 
} 
 
#order_data { 
  position: fixed; 
  height:100vh; 
  overflow:auto; 
}
<div id="container"> 
  <div id="date_range" class="row text-center">Управление</div> 
  <div id="samples_data_div"> 
    <table border='1'> 
      <thead> 
        <tr> 
          <th>1</th> 
          <th>2</th> 
          <th>3</th> 
          <th>4</th> 
        </tr> 
      </thead> 
      <tbody> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
        <tr> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
          <td>-</td> 
        </tr> 
      </tbody> 
    </table> 
  </div> 
  <div id="orders_data_div"> 
    <div id="order_data"> 
      <table border='1'> 
        <thead> 
          <tr> 
            <th>1</th> 
            <th>2</th> 
            <th>3</th> 
            <th>4</th> 
          </tr> 
        </thead> 
        <tbody> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
          <tr> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
            <td>-</td> 
          </tr> 
        </tbody> 
      </table> 
      <div> 
      </div> 
    </div>

READ ALSO
парсинг текста из html через python

парсинг текста из html через python

Требуется достать весь текст, чтобы получить

350
JS цикл c PHP переменными

JS цикл c PHP переменными

ЗдравствуйтеЗаранее спасибо за помощь

231
Как вывести массив

Как вывести массив

Скрипт,собирающий статистику о посещениях сайтаНужно вывести город и страну

259