0

The select component is shown bellow the table, instead of above. How to fix? While keeping the table responsive. This problem is worse on mobile devices.
https://codepen.io/anon/pen/wXgbPr

<div id="app">
  <h1>Vue Select - Selecting Multiple Values</h1>
  <div class="table-responsive">
    <table class="table table-bordered">
      <thead>
        <tr>
          <td>col1</td>
          <td>col2</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>
 <v-select multiple v-model="selected" :options="options"></v-select>
          </td>
          <td></td>
        </tr>
        <tr>
          <td>text</td>
          <td>text</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<script>
    Vue.component('v-select', VueSelect.VueSelect)

    new Vue({
      el: '#app',
      data: {
        selected: ['foo','bar'],
        options: ['foo','bar','baz']
      }
    })
</script>
user3599803
  • 6,435
  • 17
  • 69
  • 130
  • Can you be more descriptive on what you are trying to achieve here? – nizantz Jun 11 '18 at 03:54
  • Yes, to use a v select component inside a bootstrap table. The problem is that the table overlaps the select options, as you can easily see. I'm trying to find a fix – user3599803 Jun 11 '18 at 05:35

1 Answers1

2

If I am getting your question right, then remove the class "table-responsive" from the div wrapping the table. Add it to the table instead.

<div id="app">
  <h1>Vue Select - Selecting Multiple Values</h1>
  <div>
    <table class="table table-responsive table-bordered">
      <thead>
        <tr>
          <td>col1</td>
          <td>col2</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>
 <v-select multiple v-model="selected" :options="options"></v-select>
          </td>
          <td></td>
        </tr>
        <tr>
          <td>text</td>
          <td>text</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<script>
    Vue.component('v-select', VueSelect.VueSelect)

    new Vue({
      el: '#app',
      data: {
        selected: ['foo','bar'],
        options: ['foo','bar','baz']
      }
    })
</script>

CodePen Link

Alternatively:

<div id="app">
  <h1>Vue Select - Selecting Multiple Values</h1>
  <div class="table-responsive" style="overflow-x:visible;">
    <table class="table table-bordered">
      <thead>
        <tr>
          <td>col1</td>
          <td>col2</td>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>
 <v-select multiple v-model="selected" :options="options"></v-select>
          </td>
          <td></td>
        </tr>
        <tr>
          <td>text</td>
          <td>text</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<script>
    Vue.component('v-select', VueSelect.VueSelect)

    new Vue({
      el: '#app',
      data: {
        selected: ['foo','bar'],
        options: ['foo','bar','baz']
      }
    })
</script>
nizantz
  • 1,561
  • 1
  • 13
  • 17