I tried to import a picture to an HTML Website, the Image is in the same folder as the template is and I made a css class to import the image. When I look on the Website I see the frame of the image but there is only a question mark in it, I am working with Django if that matters. I appreciate any help. Mac user
<div>
<img src="header.jpg">
</div>
}
.header-image {
width: 100%; }
.image-container {
background-color: azure;
padding: 16px;
padding-left: 150px;
padding-right: 150px;
}
CodePudding user response:
By default django does not search and serve static file in templates directory. you have top put your image in the MEDIA directory set in your settings.py. Documentation here: https://docs.djangoproject.com/en/4.1/howto/static-files/
CodePudding user response:
Without seeing more of your code, I'm not sure but you may wish to change the class attribute of your image tag to
<img src="header.jpg">
as it's currently pointing to the image file rather than a CSS class
HTH
CodePudding user response:
Just a wild guess, it could be something like
.image-container {
background-color: azure;
padding: 16px 150px 16px 150px;
}
.header-image {
width: 100%;
}
<div >
<img src="header.jpg">
</div>