jQuery UI Resizable似乎无法使用CSS网格布局

时间:2017-08-23 10:32:02

标签: jquery css jquery-ui css-grid jquery-ui-resizable

看起来jQuery UI Resizable似乎不适用于CSS网格布局。 当元素的大小调整开始时,它会向右跳转,添加CSS网格的偏移量。

$('#resize').resizable();
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  position: relative;
}

.grid_cell {
  background-color: white;
  border: 1px solid gray;
  text-align: center;
}

#resize {
  background-color: grey;
  position: absolute;
  width: 100%;
  text-align: center;
  grid-column-start: 2;
  grid-column-end: 3
}
<link rel="stylesheet" href="//code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>

<div class="grid">
  <div class='grid_cell'>
    grid cell
  </div>
  <div class="grid_cell">
    grid cell
  </div>
  <div id="resize">
    resize me!
  </div>
</div>

的jsfiddle

https://jsfiddle.net/Bensky/91bgbfxg/11/

知道怎么解决吗?

1 个答案:

答案 0 :(得分:0)

希望以下解决方案有帮助:

JS fiddle link

$('#resize').resizable();
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  position: relative;
}
.grid_cell {
  background-color: white;
  border: 1px solid gray;
  text-align: center;
}

#resize {
  background-color: grey;
  position: absolute;
  width: 100%;
  text-align: center;
  grid-column-start:1;
  grid-column-end: 3
}
<div class="grid">
  <div class='grid_cell'>
    grid cell
  </div>
  <div class="grid_cell">
    grid cell
  </div>
  <div id="resize">
    resize me!
  </div>
</div>