繁体   English   中英

Ajax调用后如何重新加载CSS

[英]How to reload CSS after ajax call

我正在尝试修复页面上的CSS格式实际上我正在使用Django无休止的分页
要在页面滚动上加载我的内容,但是当加载新内容时,应用于页面的CSS无法工作或必须刷新......所以请告诉我如何将CSS应用于通过ajax调用加载的新内容。 。

index.html:

<html>
<head>
    <title>Fashion</title>
    <link rel="stylesheet" type="text/css" href="static/css/style.css">
</head>
<body>


<div class="product_container">
    <ul class="product_list">
        <div class="endless_page_template">
            {% include page_template %}
        </div>
    </ul>
</div>
{% block js %}
<script src="http://code.jquery.com/jquery-latest.js"></script> 
<script src="static/js/endless_on_scroll.js"></script>
<script src="static/js/endless-pagination.js"></script>    
<script>
    $.endlessPaginate({paginateOnScroll: true,
    endless_on_scroll_margin : 10,
    paginateOnScrollChunkSize: 5        
});</script>
{% endblock %}
</body>
</html>

style.css:

.product_list
{
    margin:0;
    padding:0;
    list-style-type: none;
}

.product_list li
{
    margin:0;
    padding:0;
    height:150px;
    margin-bottom:5px;
}

.product_container
{
    width:800px;
    column-gap: 0;
    column-count: 2;
    -moz-column-gap: 0;
    -moz-column-count: 2;
    -webkit-column-gap: 0;
    -webkit-column-count: 2;
}

index_page.html:

{% load endless %}
{% paginate 10 contextList %}
{% for item in contextList %}
    <li>
        <a href="{{ item.productURL }}" ><img src="/images/{{ item.image_paths.0 }}/" height="100" width="100" border='1px solid'/></a>
        <br>
        <span class="price">
        <span class="mrp">MRP : {{ item.productMRP}}</span>
        {% if item.productPrice %}<br>
        <span class="discounted_price">Offer Price : {{ item.productPrice}}</span>
        {%endif%}
        </span>
    </li>  
{% endfor %}
</ul>
{% show_more "even more" "working" %}

我已经应用CSS禁用ul符号,但是在ajax调用新数据后包含项目符号,这意味着新数据CSS无法正常工作。

尝试添加以下CSS:

li {
    list-style-type: none;
}

如果这样.product_list ,那么您的css选择器.product_list就是不正确的,您需要以一种可以捕获所有li的方式来指定它。

我遇到了同样的问题,并找到了仅将CSS样式内联到已加载标签中的解决方案。

这不是最佳做法,但对我有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM