I have a little experience with CSS and HTML, but currently working on a website for a friend of mine. I'm using Wordpress and he wants a picture in the header and thats where I am currently stuck.
I read that it is a good practice to set the image as the background image inside a div
tag. My problem is that the image is not showing, so I am assuming that I have an error with the path I am using. When inserting a picture that is online, it works perfectly.
Here's my div inside the header.php file:
<div id="bottom-header-section"></div>
And here's the CSS code:
#bottom-header-section {
background-image: url('\images\title.jpg');
height: 95px;
width: 613px;
margin: inherit;
margin-top: 15%;
margin-left: 35%;
background-position: right bottom;
background-repeat: no-repeat;
}
If I delete the background-image completely, I can see that the size of the div
gets smaller. I tried every different path that came to my mind..
Also, what is the best way to make the image responsive?
尝试使用'../images/title.jpg'-应该可以
It depends on where your image and stylesheet are located within the file tree.
This is how the path should read:
#bottom-header-section {
background-image: url('../images/title.jpg');
}
The tree should something like this:
wp-content - themes - your-theme - images - title.jpg - css - style.css
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.