【发布时间】:2020-08-30 11:01:34
【问题描述】:
所以我不确定我在这里做错了什么。我尝试了几种不同的方法,如果我通过我的 HTML 手动将我的照片插入到 Jumbotron 所在的位置,我的图片会加载,尽管有我不想要的填充并且它不在背景中。我不明白我在这里做错了什么。我尝试了两种不同的方法,但都不起作用。唯一有效的方法是将img src= 直接进入 Jumbotron 部分,但就像我说的那样,这就是我想要的。那么我在这里做错了什么?
项目网址
from django.contrib import admin
from django.urls import path, include
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('dating_app.urls', namespace= 'dating_app')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
settings.py
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "dating_app/static"),
]
home.html/styles
.JumboHeaderImg{
background-image: url("/Users/papichulo/Documents/DatingAppCustom/dating_app/static/images/jumbo.jpg");
}
.JumboHeaderImg{
background-image: "{% static 'images/jumbo.jpg' %}";
home.html/jumbotron
<div class="jumbotron JumboHeaderImg">
styles.css
.navbar-nav li{
padding-left:35px;
padding-right:10px;
margin-top: -20px;
margin-bottom: -20px;
}
/* Modify the backgorund color */
.navbar-custom {
background-color: #ffffff;
}
.jumbotron{
background-color: #f76062228c;
}
.navbar .nav-item{
color: red;
}
.notification {
text-decoration: none;
padding:50;
position: relative;
display: inline-block;
}
.notification .badge {
position: absolute;
top: -15px;
right: -10px;
padding: 5px 5px;
border-radius: 40%;
background-color: red;
color: white;
}
【问题讨论】:
-
home.html stackoverflow.com/questions/6052341/…987654321@的样式文件在哪里
-
那里得到它
-
从我看到的代码来看,代码很好,所以你需要调试。将图像更改为 100% 工作图像,即mywebsite.com/myimage.jpg。它有效吗?如果是这样,问题是服务器看到您的图像链接。如果没有,那么你有一些 CSS 覆盖了 background-img 属性。右击 Jumbotron 和 Inspect,看看 background-img 属性设置成什么
标签: css django bootstrap-4