question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

table responsive not work

See original GitHub issue

In my table ,responsive not work

    <b-table
      fixed
      ref="selectableTable"
      selectable
      select-mode="multi"
      :items="items"
      :fields="fields"
      @row-selected="onRowSelected"
      responsive
      outlined
      :busy="isBusy"
      striped
      bordered
      hover
      small
      show-empty
      empty-text="空空如也"
      stacked="md"
    >
      <!-- Example scoped slot for select state illustrative purposes -->
      <template v-slot:table-busy>
        <div class="text-center text-danger my-2">
          <b-spinner class="align-middle"></b-spinner>
          <strong> 正在努力加载数据</strong>
        </div>
      </template>
      <template v-slot:cell(IsSelected)="{ rowSelected }">
        <template v-if="rowSelected">
          <b-icon icon="lock"></b-icon>
          <span class="sr-only">Selected</span>
        </template>
        <template v-else>
          <b-icon icon="unlock"></b-icon>
          <span class="sr-only">Not selected</span>
        </template>
      </template>
      <template v-slot:cell(index)="data">
        {{ data.index + 1 }}
      </template>
      <template v-slot:cell(is_survey)="data">
        <a :class="data.item.is_survey ? 'text-success' : 'text-danger'">{{
          data.item.is_survey ? "是" : "否"
        }}</a>
      </template>
      <template v-slot:cell(progress)="data">
        <a
          :class="
            parseInt(data.item.progress) == 100
              ? 'text-success'
              : parseInt(data.item.progress) < 100 &&
                parseInt(data.item.progress) > 90
              ? 'text-info'
              : parseInt(data.item.progress) < 90 &&
                parseInt(data.item.progress) > 80
              ? 'text-warning'
              : parseInt(data.item.progress) < 80 &&
                parseInt(data.item.progress) > 60
              ? 'text-primary'
              : parseInt(data.item.progress) == 0
              ? 'text-danger'
              : 'text-dark'
          "
          >{{ data.item.progress }}</a
        >
      </template>
    </b-table>

360截图20200111012057279

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
nejinncommented, Jan 27, 2020

I am sorry!In my project, this work perfect!

  <div class="table-responsive">
    <b-table table-class="text-nowrap" responsive>
    </b-table>
  </div>
1reaction
nejinncommented, Jan 26, 2020

e-layout: fixed sty

fixed and responsive modes do not always play well together.

fixed layout, where every column is made equal widths (unless a width is provided via style/css per column) uses table-layout: fixed style, which looks at the first row to determine the width the table needs to fit in the current container’s max width.

Either remove the fixed prop, or control the widths of the column headers:

<b-table fixed responsive ...>
  <!-- this applied to all header cells that do not have an explicit slot provided -->
  <template v-slot:head()="scope">
    <div style="width:20rem">{{ scope.label }}</div>
  </template>
</b-table>

Or use the table-colgroup slot to set widths for the column(s):

<b-table fixed responsive ...>
  <template v-slot:table-colgroup>
    <col style="width: 10rem">
    <col style="width: 20rem">
    <col>
    <col style="width: 30rem">
    <!-- add as many <col> elements as needed -->
  </template>
</b-table>

<col> entries without a width set will all be set to equal widths to take up the remaining available space. So it is usually a good idea to set a width for each column (specifically when using fixed layout mixed with responsive)

We can dosomething: add

< div class="table-responsive" > < b-table ></b-table></div>

add table-class=“text-nowrap” in < b-table >。horizontal scrollbar works!

  <div class="table-responsive">
    <b-table
      ref="selectableTable"
      selectable
      select-mode="multi"
      :items="items"
      :fields="fields"
      @row-selected="onRowSelected"
      outlined
      :busy="isBusy"
      striped
      bordered
      hover
      small
      show-empty
      empty-text="空空如也"
      stacked="md"
      :sticky-header="true"
      table-class="table-responsive text-nowrap"
    ></b-table>
  </div>
Read more comments on GitHub >

github_iconTop Results From Across the Web

bootstrap table is not responsive - css - Stack Overflow
Make sure you checked you have inserted enough data in table. Sometimes there is just not enough data to trigger 'table-responsive' property.
Read more >
table-responsive class does not take full width #24638 - GitHub
A table with the table-responsive class will not render at full width. I'm not sure why it works in the example in the...
Read more >
Tables · Bootstrap v5.0
Responsive tables allow tables to be scrolled horizontally with ease. Make any table responsive across all viewports by wrapping a .table with .table-responsive...
Read more >
Why is the scroll in bootstrap table-responsive does not work ...
I am using bootstrap and i have very long table and in any browser, it shows part of this table and i can...
Read more >
How to Make a Table Responsive in a Few Easy Steps
What can you do? You can make tables responsive. Responsive tables will become smaller when possible. If not possible, they can read just...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found