Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/86.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Django表2-在列标题中显示排序指示器箭头_Python_Html_Css_Django - Fatal编程技术网

Python Django表2-在列标题中显示排序指示器箭头

Python Django表2-在列标题中显示排序指示器箭头,python,html,css,django,Python,Html,Css,Django,我刚刚开始在我的一个项目中使用django-tables2。除了一件我一直坚持的事情->在列标题中显示一个箭头图像,指示表的排序方式(如果它现在是按该列排序的话),一切都很好 我只是使用枯燥的默认值{%render_table%}来呈现表,所以我没有直接访问它吐出的HTML的权限,我也不想为了添加箭头而重写整个过程 我试着通过CSS添加它们,我已经非常接近于让它工作,但无法达到我想要的程度。我在样式表中添加了以下内容: th.asc { background: url("arrow-up

我刚刚开始在我的一个项目中使用django-tables2。除了一件我一直坚持的事情->在列标题中显示一个箭头图像,指示表的排序方式(如果它现在是按该列排序的话),一切都很好

我只是使用枯燥的默认值{%render_table%}来呈现表,所以我没有直接访问它吐出的HTML的权限,我也不想为了添加箭头而重写整个过程

我试着通过CSS添加它们,我已经非常接近于让它工作,但无法达到我想要的程度。我在样式表中添加了以下内容:

th.asc {
    background: url("arrow-up.gif/") no-repeat scroll right 0.4em transparent;
}

th.desc {
    background: url("arrow-down.gif/") no-repeat scroll right 0.4em transparent;
}
它在右标题和右方向显示箭头,但箭头远离列标题的右侧,比文本更远。由于列标题名称的长度可变,我无法知道如何为每个不同的列标题设置0.4值。我不能把它设置在文本的左边,因为它在第th个标记之外,背景图像根本不显示

有没有一种简单的方法可以将自定义HTML添加到相应的列标题中?还是我一直在编辑tables2用来生成表的table.html?

您可以阅读以下内容:

实际上,为了使用django_表2,上面文章中的CSS必须减少到3行:

table.table thead th.sortable { background: url('../img/sort_both.png') no-repeat center right; }
table.table thead th.asc { background: url('../img/sort_asc.png') no-repeat center right; }
table.table thead th.desc { background: url('../img/sort_desc.png') no-repeat center right; }