使用 django-tables2 时如何更改字体大小和/或字体系列?

How do I change the font size and / or font family when using django-tables2?

Table 定义:

''' 将 django_tables2 作为表格导入 从 django_tables2.utils 导入 A 来自 cliente.models 导入客户

class 浏览客户端(tables.Table):

nome = tables.Column(verbose_name='Nome',orderable=True)
tipo = tables.Column(verbose_name='Tipo',orderable=False)
cidres = tables.Column(verbose_name='Cidade',orderable=False)
estado = tables.Column(verbose_name='UF',orderable=False)
celular = tables.Column(verbose_name='Celular',orderable=False)
email = tables.Column(verbose_name='E-Mail',orderable=False)
dddres = tables.Column(verbose_name='DDD Res',orderable=False)
foneres = tables.Column(verbose_name='Fone Res',orderable=False)

class Meta:

    model = Cliente 
    template_name = "django_tables2/bootstrap4.html"
    fields = ('nome',
              'tipo',
              'cidres',
              'estado',
              'celular',
              'email',
              'dddres',
              'foneres')

    attrs = {"class": "table table-striped"}

'''

模板

{% extends 'base.html' %}
{% load render_table from django_tables2 %}
{% block content %}

    {% include 'partials/_menu4.html' %}

    {% render_table table %}   

    {% include 'partials/_footer.html' %}
    
{% endblock %}

结果对我客户的口味来说有点太大了。感谢您的帮助。

在此处将自定义 class 添加到您的 table:

attrs = {"class": "table table-striped clients-table"}

然后使用 <style> 块向您的模板添加样式:

<style>
    .clients-table {
        font-size: 10pt;
    }

</style>

太棒了!!马上就见效了!