首页 > 解决方案 > 改变背景颜色没有效果

问题描述

我无法使用我的 CSS 样式表更改背景颜色。

这是 HTML(使用 Django);目前在列表中有三个列表。

{% for listing in listings %}
    <ul>
        <li class="item"><img src="{{ listing.pic}}"> {{ listing }}</li>
        <div class="item-description">{{ listing.description }}</div>
    </ul>
{% endfor %}

这是CSS

body {
padding: 10px;
background-color: green !important;
}
ul {
    list-style: none;
    background-color: green !important;
}
.item {
    background-color: blue !important;
    height: 200px;
}
.item-description {
    background-color: purple !important;
}

如您所见,我已经尝试添加 !important 并为元素指定高度。还有一个我尝试删除的引导程序链接。但是,没有任何效果;页面和所有元素保持白色。

标签: htmlcssbackground-color

解决方案


推荐阅读