【问题标题】:Flask - show flash messages in same place, not at top of pageFlask - 在同一位置显示 Flash 消息,而不是在页面顶部
【发布时间】:2021-09-30 15:40:07
【问题描述】:
{% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                {% for category, message in messages %}
                    <div class="alert alert-{{ category }}"
                    style="margin-right: -500px; margin-left: -500px; text-align: center;">
                        {{ message }}
                    </div>
                {% endfor %}
            {% endif %}
{% endwith %}

我有一个页面很长的应用,当执行一个带有闪消息的操作时,闪消息是否可以显示在当前位置,而不是转到页面顶部?

【问题讨论】:

    标签: python html css flask


    【解决方案1】:

    您可以使用position:fixed 将您的 div 固定在页面上。

    我也让它在页面中心弹出。

    <div class="alert alert-{{ category }} "style="position:fixed; left: 50%; transform: translate(-50%, 0);">
                            {{ message }}
                        </div>
    

    【讨论】:

      猜你喜欢
      • 2013-01-23
      • 2016-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-21
      • 2011-07-15
      • 2018-09-09
      • 1970-01-01
      相关资源
      最近更新 更多