Javascript 默认为水平滚动的表格

Javascript 默认为水平滚动的表格,javascript,html,css,django,Javascript,Html,Css,Django,我在我的项目中得到了这个表:,但我希望默认的鼠标滚动是水平的,而不是垂直的。我该怎么做 <div id="divtest" class="container mt-2 mb-2"> <table id="tableteste" class="tabletest" data-toggle="table" data-search="true" data-virtual-scroll="true" data-de

我在我的项目中得到了这个表:,但我希望默认的鼠标滚动是水平的,而不是垂直的。我该怎么做

<div id="divtest" class="container mt-2 mb-2">
                <table id="tableteste" class="tabletest" data-toggle="table" data-search="true"
                    data-virtual-scroll="true" data-detail-view="true" data-show-export="true"
                    data-click-to-select="true" data-detail-formatter="detailFormatter">
                    <thead>
                        <tr>
                            <th data-field="tipo" data-sortable="true">Tipo </th>
                            <th data-field="codigo" data-sortable="true">Código </th>
                            <th data-field="descricao" data-sortable="false">Descrição </th>
                            <th data-field="quantidade" data-sortable="true">Quantidade (Und) </th>
                            {% for i in lista_estoque %}
                            <th data-field="{{i.fantasia}}" data-sortable="true">{{i.fantasia}}</th>
                            {% endfor %}
                            <th data-field="valorun" data-sortable="true">Valor Unitário (R$) </th>
                            <th data-field="valortot" data-sortable="true">Valor Total (R$) </th>


                        </tr>
                    </thead>
                    <tbody>
                        {% for i in lista_produto %}
                        <tr>

                            <td>{{i.tipo}}</td>
                            <td class="id{{i.id}}">{{i.codigo}}- <span style="color: red;">{{i.id}}</span></td>
                            <td class="id{{i.id}}">{{i.produto_desc}}</td>
                            <td></td>
                            {%if i.tipo == 'PI'%}
                            <td class="id{{i.id}}"> {{i.valoruni}}</td>
                            {%else%}
                            <td class="id{{i.id}}"> {{i.compvalortot}}</td>
                            {%endif%}
                            {%if i.tipo == 'PI'%}
                            <td class="id{{i.id}}"> {{i.valoruniDol}}</td>
                            {%else%}
                            <td class="id{{i.id}}"> {{i.compvalortotDol}}</td>
                            {%endif%}

                        </tr>
                        {% endfor %}

                    </tbody>
                </table>
            </div>

蒂波
科迪戈
描述
量化数据(Und)
{lista_estoque%中的i的%s}
{{i.fantasia}}
{%endfor%}
瓦罗单位(南非兰特)
总价值(R$)
{lista_produto%}
{{i.tipo}}
{{i.codigo}}-{i.id}
{{i.produto_desc}}
{%如果i.tipo='PI%}
{{i.valoruni}}
{%else%}
{{i.compvalortot}
{%endif%}
{%如果i.tipo='PI%}
{{i.valoruniDol}}
{%else%}
{{i.compvalortotDol}}
{%endif%}
{%endfor%}

我找到的解决方案:

$.fn.hScroll = function (options) {
                function scroll(obj, e) {
                    var evt = e.originalEvent;
                    var direction = evt.detail ? evt.detail * (-120) : evt.wheelDelta;

                    if (direction > 0) {
                        direction = $(obj).scrollLeft() - 120;
                    }
                    else {
                        direction = $(obj).scrollLeft() + 120;
                    }

                    $(obj).scrollLeft(direction);

                    e.preventDefault();
                }

                $(this).width($(this).find('div').width());

                $(this).bind('DOMMouseScroll mousewheel', function (e) {
                    scroll(this, e);
                });
            }

            $(".fixed-table-body").hScroll();

也许这会有帮助谢谢你的帮助,罗纳德!