How to use CSS/JavaScript to beautify the `archiveFilters` tag generated filter interface to enhance user experience?

Calendar 👁️ 63

As an experienced website operations expert, I know that user experience is crucial for the success of a website, especially in complex filtering functions. AnQiCMS (AnQiCMS) providesarchiveFiltersLabels, provide great convenience for us to quickly build document parameter filtering interface.However, relying solely on default styles often fails to meet the high requirements of modern websites for aesthetics and interactivity.

Today, let's delve into how to apply CSS and JavaScript, toarchiveFiltersbeautifully design the generated filter interface, thereby significantly enhancing the user experience.

Get to knowarchiveFiltersThe default structure

Before starting to beautify, we first need to understandarchiveFiltersHow labels are used in templates and what HTML structure they will generate. According to the AnQiCMS template tag documentation,archiveFiltersUsed to build filtering conditions based on document parameters. Typical usage is as follows:

{# 示例模板代码 #}
<div>
    <div>参数筛选:</div>
    {% archiveFilters filters with moduleId="1" allText="默认" %}
        {% for item in filters %}
        <ul>
            <li>{{item.Name}}: </li> {# 筛选组名称,例如“房屋类型”、“房间大小” #}
            {% for val in item.Items %}
            <li class="{% if val.IsCurrent %}active{% endif %}"><a href="{{val.Link}}">{{val.Label}}</a></li> {# 筛选选项 #}
            {% endfor %}
        </ul>
    {% endfor %}
</div>

After this template code is rendered, it will roughly generate an HTML structure like this:

<div class="filter-wrapper">
    <div class="filter-title">参数筛选:</div>
    <!-- 第一个筛选组,例如“房屋类型” -->
    <ul class="filter-group">
        <li class="filter-group-name">房屋类型: </li>
        <li class="filter-option active"><a href="/path/to/filter?type=apartment">公寓</a></li>
        <li class="filter-option"><a href="/path/to/filter?type=villa">别墅</a></li>
    </ul>
    <!-- 第二个筛选组,例如“房间大小” -->
    <ul class="filter-group">
        <li class="filter-group-name">房间大小: </li>
        <li class="filter-option"><a href="/path/to/filter?size=one">一居室</a></li>
        <li class="filter-option active"><a href="/path/to/filter?size=two">两居室</a></li>
    </ul>
    <!-- ... 更多筛选组 ... -->
</div>

Note that a key point is: each filter group ({{item.Name}}and its options) are wrapped in a separate<ul>tag. At the same time, the currently selected filter option will have aactiveClasses. Understanding this structure is the foundation for precise CSS styling and JavaScript interaction.

Use CSS for interface beautification.

CSS is the most direct means to improve the appearance of the filtering interface.We can make the filter interface professional, easy to read, and consistent with the brand style through a series of style rules.

  1. Overall layout and responsive design:To ensure that the filter group displays well on different screen sizes, we can use Flexbox or Grid layout.On the desktop, the filter group can be horizontally aligned; on the mobile end, it can be stacked.

    `css /* public/static/css/custom-filters.css */ .filter-wrapper {

    padding: 15px;
    background-color: #f8f8f8;
    border-radius: 8px;
    margin-bottom: 20px;
    

    }

    .filter-title {

    font-size: 18px;
    font-weight: bold;
    color: #333;
    margin-bottom: 15px;
    

    }

    .filter-group {

    display: flex; /* 让筛选组内的元素水平排列 */
    flex-wrap: wrap; /* 允许选项换行 */
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 1px dashed #eee; /* 区分不同筛选组 */
    padding-bottom: 10px;
    

    } .filter-group:last-of-type {

    border-bottom: none; /* 最后一个筛选组不需要底部边框 */
    margin-bottom: 0;
    padding-bottom: 0;
    

    }

    .filter-group-name {

    font-weight: bold;
    color: #666;
    margin-right: 15px;
    white-space: nowrap; /* 防止名称换行 */
    

    }

    .filter-option {

    list-style: none; /* 移除默认列表点 */
    margin-right: 10px;
    margin-bottom: 8px; /* 确保在多行显示时有间距 */
    

    }

    .filter-option a {

    display: block;
    padding: 5px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    color: #555;
    text-decoration: none;
    transition: all 0.2s ease-in-out; /* 平滑过渡效果 */
    font-size: 14px;
    

    }

    .filter-option a:hover {

    border-color: #007bff;
    color: #007bff;
    background-color: #e9f7ff;
    

    }

    /* Selected state style */ .filter-option.active a {

    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
    font-weight: bold;
    

    }

    /* Responsive adjustment */ @media (max-width: 768px) {

    .filter-group {
        flex-direction: column; /* 移动端筛选组堆叠 */
        align-items: flex-start;
    }
    .filter-group-name {
        margin-bottom:
    

Related articles

What are the specific application scenarios of the `IsCurrent` field in the `archiveFilters` tag in front-end development?

Good, as an experienced website operations expert, I am very willing to delve into the specific application scenarios of the `archiveFilters` tag's `IsCurrent` field in front-end development in AnQi CMS.We will integrate technical details into practical applications in a natural and fluent manner, hoping to bring you some practical inspiration.--- ## Deep Analysis of Anqi CMS Front-end Development: The Magic of `IsCurrent` Field in `archiveFilters` Tag In the Anqi CMS ecosystem

2025-11-06

How to combine the "Keyword Library" feature of AnQi CMS to provide richer filtering vocabulary for `archiveFilters`?

As an experienced website operation expert, I am well aware that in today's era of content explosion, how to efficiently organize and display content so that users can quickly find the information they need is the key to improving user experience and SEO performance.AnQiCMS (AnQiCMS) with its powerful feature set, provides us with many operational tools.Today, we will delve into a seemingly simple yet highly promising combination application: how to cleverly combine the 'keyword library' and 'content model' of Anqi CMS to enrich the filtering vocabulary of the `archiveFilters` feature

2025-11-06

Does the `archiveFilters` tag support secondary or multi-level cascading selection, for example, selecting provinces first and then cities?

As an experienced website operations expert, I am well aware that the filtering function plays a crucial role in content management and user experience.Especially when faced with massive amounts of information, an efficient and intuitive filtering system can greatly enhance the efficiency of users in finding the content they need.AnQiCMS (AnQiCMS) has won a lot of praise in the content operation field with its flexible functions and powerful extensibility.

2025-11-06

How to avoid duplicate content or empty list situations on the `archiveFilters` filter results page?

As an experienced website operations expert, I am well aware of the core role of the content management system (CMS) in website operations.AnQiCMS with its efficient and flexible features, provides many conveniences for us to build personalized content display.The `archiveFilters` tag is undoubtedly a powerful tool for enhancing the user's content search experience and implementing multi-dimensional content filtering.

2025-11-06

How will the `archiveFilters` tag handle if the document does not have a value for a certain filter parameter?

As an experienced website operations expert, I often deal with content management systems in my daily work and understand the importance of flexible use of template tags for website performance and user experience.AnQiCMS (AnQiCMS) with its powerful features and high performance brought by the Go language has become the preferred choice for many enterprises and operation teams.Today, let's delve into a detail issue that may be encountered in template development and content operation: **What will happen when a filter parameter dependent on the `archiveFilters` tag does not have a corresponding value?

2025-11-06

`archiveFilters` tag supports dropdown menu or checkbox form of filtering interface?

AnQiCMS provides a highly flexible solution in content management and display, especially in handling dynamic content filtering, where its `archiveFilters` tag plays a core role.Does the `archiveFilters` tag support a dropdown menu or checkbox form of the filter interface?This question can be understood as: The `archiveFilters` tag itself does not directly generate visible UI elements, such as dropdown menus or checkboxes

2025-11-06

How to quickly view the original data output by the `archiveFilters` tag during template debugging?

As an experienced website operations expert, I know that quickly and effectively debugging template tags in AnQiCMS (AnQiCMS) template development and maintenance process is the key to improving efficiency.Especially when we need to handle tags like `archiveFilters` that return complex data structures, it is particularly important to quickly discern the original data within them.This is not just to verify whether the label output is correct, but also to quickly locate and solve problems when encountering them.

2025-11-06

`archiveFilters` label can integrate third-party traffic statistics tools to track the usage of the filtering function?

As an experienced website operations expert, I know that every user interaction detail contains the potential to enhance the value of the website.AnQiCMS (AnQiCMS) provides us with a wide range of space to implement our operational strategies with its powerful content management capabilities and flexible template system.Today, let's delve into a frequently discussed issue in精细化运营: Can the `archiveFilters` tag integrate third-party traffic statistics tools to track the usage of the filtering function?

2025-11-06