以下是我提到图像的唯一代码:

在html和css文件中:

<button type="submit" class="task-item-button">
<img src="{% static 'x.svg' %}" alt="Close icon">
</button>

.task-item-button {
  position: absolute;
    top: 10px; /* Adjust the top position */
    right: 10px; /* Adjust the right position */
    width: 20px;
    height: 20px;
    color: red;
    padding: 0; 
    border: none; 
    background: none;
    border-radius: 8px;
    cursor: pointer;
    
}
.task-item-button img {
  width: 20px; /* Adjust the width of the image as needed */
  height: 20px; /* Adjust the height of the image as needed */
}

我在最上面有{% load static %}个.

除此之外,我在任何地方都没有提到过这些图片.

静态的 struct 如下所示:

enter image description here

谢谢你的帮助

推荐答案

选中所有步骤:

# Steps:
    # 1 - Create (static) folder in Root Directory of Project
    # 2 - Paste Your Static Files Folder in (static) Folder (js,css,images...etc)
    # 3 - Now Do Setting in (setting.py)
          STATIC_URL = '/static/'

          STATICFILES_DIRS = [os.path.join(BASE_DIR,'static')]
    # 4 - add {% load static %} tag on top of html page
    # 5 - Now use ({% static 'assets/image.jpg' %}) tag in HTML File for calling static files
    # 6 - Done

Html相关问答推荐

Tailwincss:自动设置网格高度

我能阻止浏览器跨跨区边界折叠空格吗?

用于删除页面页眉上的超链接的CSS

如何在html和css中创建动态调整大小的表元素

图像不在HTML文件中显示

这<;td&>如何溢出<;表>;?

如何更改Django中的默认按钮?

Django HTML标记-Merge for Loop with Conditional语句

Swift 以编程方式在 YouTube 嵌入视频中进入全屏

UL 的行为就像它不属于任何类别

为什么我的 html 对话框在 React 中没有渲染在我的内容之上?

悬停时宽度从 0 过渡到自动

模拟另一个输入值设置表单输入的数值

如何消除线性渐变线的模糊?

奇怪的幻影 div 命名为

如何使我的下拉菜单响应?

发光效果html动画

当另一个 div 的高度改变或执行其内容的换行时,将 flex 方向更改为列

我的卡片内容无法在 bootstrap 5 中正确居中

如何计算没有根元素的先前 html 标记(lxml python3)编辑:还获取元素